|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Draw shadows under child formsI seem to have a problem with drawing shadows behind child forms. Here is my code: Private Const CS_DROPSHADOW As Long = &H20000 Private Const GCL_STYLE As Long = -26 Private Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" (ByVal lngHandler As Long, ByVal lngIndex As Long) As Long Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" (ByVal lngHandler As Long, ByVal lngIndex As Long, ByVal lngNewClassLong As Long) As Long .... SetClassLong Me.hWnd, GCL_STYLE, GetClassLong(Me.hWnd, GCL_STYLE) Or CS_DROPSHADOW .... The above source code works perfectly for the parent form, but when I open a form using frmForm.Show -or- frmForm.Show vbModal, Me -or- frmForm.Show , Me -or- frmForm.Show vbModal the shadow is drawn correctly behind the child form when it becomes visible, but once I move the child form around, the shadow is drawn behind the parent window (and therefore not visible; none of the forms is set to be top-most). I also tried to apply the style to the parent and the child windows, but it won't help. To see this problem, simply create a project with two forms and use the drop shadow code I posted in the Form_Load event of the first form and create a button which calls the second form; then move the second form around. Any idea how to fix this? Regards, Sebastian Works for me...
What I did: 1) Place constants and declarations in Form1 (private) 2) Made a call to the SetClassLong in Form1's load event 3) Placed a command button on form1 to show form2 (Form2.Show) 4) Ran the app and all worked as expected SetClassLong (info): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windowclasses/windowclassreference/windowclassfunctions/setclasslong.asp -- Show quoteHide quoteChris Hanscom - Microsoft MVP (VB) Veign's Resource Center http://www.veign.com/vrc_main.asp Veign's Blog http://www.veign.com/blog -- "Sebastian Mares" <SebastianMa***@discussions.microsoft.com> wrote in message news:0DBD516C-A046-4F7E-AA75-D99DD7675585@microsoft.com... > Hi there! > > I seem to have a problem with drawing shadows behind child forms. Here is my > code: > > Private Const CS_DROPSHADOW As Long = &H20000 > Private Const GCL_STYLE As Long = -26 > > Private Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" > (ByVal lngHandler As Long, ByVal lngIndex As Long) As Long > Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" > (ByVal lngHandler As Long, ByVal lngIndex As Long, ByVal lngNewClassLong As > Long) As Long > ... > SetClassLong Me.hWnd, GCL_STYLE, GetClassLong(Me.hWnd, GCL_STYLE) Or > CS_DROPSHADOW > ... > > The above source code works perfectly for the parent form, but when I open a > form using > > frmForm.Show > -or- > frmForm.Show vbModal, Me > -or- > frmForm.Show , Me > -or- > frmForm.Show vbModal > > the shadow is drawn correctly behind the child form when it becomes visible, > but once I move the child form around, the shadow is drawn behind the parent > window (and therefore not visible; none of the forms is set to be top-most). > I also tried to apply the style to the parent and the child windows, but it > won't help. > > To see this problem, simply create a project with two forms and use the drop > shadow code I posted in the Form_Load event of the first form and create a > button which calls the second form; then move the second form around. > > Any idea how to fix this? > > Regards, > Sebastian Weird... Did you move the second form a bit around? I just noticed that when
you call the second form using "Form2.Show , Me", the problem also appears when clicking on the parent form and then on the child form again (basically make it lose focus and then make it gain focus again). Show quoteHide quote "Veign" wrote: > Works for me... > > What I did: > 1) Place constants and declarations in Form1 (private) > 2) Made a call to the SetClassLong in Form1's load event > 3) Placed a command button on form1 to show form2 (Form2.Show) > 4) Ran the app and all worked as expected > > > SetClassLong (info): > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windowclasses/windowclassreference/windowclassfunctions/setclasslong.asp > > -- > Chris Hanscom - Microsoft MVP (VB) > Veign's Resource Center > http://www.veign.com/vrc_main.asp > Veign's Blog > http://www.veign.com/blog > -- > > > "Sebastian Mares" <SebastianMa***@discussions.microsoft.com> wrote in > message news:0DBD516C-A046-4F7E-AA75-D99DD7675585@microsoft.com... > > Hi there! > > > > I seem to have a problem with drawing shadows behind child forms. Here is > my > > code: > > > > Private Const CS_DROPSHADOW As Long = &H20000 > > Private Const GCL_STYLE As Long = -26 > > > > Private Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" > > (ByVal lngHandler As Long, ByVal lngIndex As Long) As Long > > Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" > > (ByVal lngHandler As Long, ByVal lngIndex As Long, ByVal lngNewClassLong > As > > Long) As Long > > ... > > SetClassLong Me.hWnd, GCL_STYLE, GetClassLong(Me.hWnd, GCL_STYLE) Or > > CS_DROPSHADOW > > ... > > > > The above source code works perfectly for the parent form, but when I open > a > > form using > > > > frmForm.Show > > -or- > > frmForm.Show vbModal, Me > > -or- > > frmForm.Show , Me > > -or- > > frmForm.Show vbModal > > > > the shadow is drawn correctly behind the child form when it becomes > visible, > > but once I move the child form around, the shadow is drawn behind the > parent > > window (and therefore not visible; none of the forms is set to be > top-most). > > I also tried to apply the style to the parent and the child windows, but > it > > won't help. > > > > To see this problem, simply create a project with two forms and use the > drop > > shadow code I posted in the Form_Load event of the first form and create a > > button which calls the second form; then move the second form around. > > > > Any idea how to fix this? > > > > Regards, > > Sebastian > > > Yup...Move it around, closed the parent, clicked around and the shadow
remained on Form2... -- Show quoteHide quoteChris Hanscom - Microsoft MVP (VB) Veign's Resource Center http://www.veign.com/vrc_main.asp Veign's Blog http://www.veign.com/blog -- "Sebastian Mares" <SebastianMa***@discussions.microsoft.com> wrote in http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windowclasses/windowclassreference/windowclassfunctions/setclasslong.aspmessage news:53C92182-4B82-40B0-9B60-E69384368B48@microsoft.com... > Weird... Did you move the second form a bit around? I just noticed that when > you call the second form using "Form2.Show , Me", the problem also appears > when clicking on the parent form and then on the child form again (basically > make it lose focus and then make it gain focus again). > > "Veign" wrote: > > > Works for me... > > > > What I did: > > 1) Place constants and declarations in Form1 (private) > > 2) Made a call to the SetClassLong in Form1's load event > > 3) Placed a command button on form1 to show form2 (Form2.Show) > > 4) Ran the app and all worked as expected > > > > > > SetClassLong (info): > > Show quoteHide quote > > > > -- > > Chris Hanscom - Microsoft MVP (VB) > > Veign's Resource Center > > http://www.veign.com/vrc_main.asp > > Veign's Blog > > http://www.veign.com/blog > > -- > > > > > > "Sebastian Mares" <SebastianMa***@discussions.microsoft.com> wrote in > > message news:0DBD516C-A046-4F7E-AA75-D99DD7675585@microsoft.com... > > > Hi there! > > > > > > I seem to have a problem with drawing shadows behind child forms. Here is > > my > > > code: > > > > > > Private Const CS_DROPSHADOW As Long = &H20000 > > > Private Const GCL_STYLE As Long = -26 > > > > > > Private Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" > > > (ByVal lngHandler As Long, ByVal lngIndex As Long) As Long > > > Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" > > > (ByVal lngHandler As Long, ByVal lngIndex As Long, ByVal lngNewClassLong > > As > > > Long) As Long > > > ... > > > SetClassLong Me.hWnd, GCL_STYLE, GetClassLong(Me.hWnd, GCL_STYLE) Or > > > CS_DROPSHADOW > > > ... > > > > > > The above source code works perfectly for the parent form, but when I open > > a > > > form using > > > > > > frmForm.Show > > > -or- > > > frmForm.Show vbModal, Me > > > -or- > > > frmForm.Show , Me > > > -or- > > > frmForm.Show vbModal > > > > > > the shadow is drawn correctly behind the child form when it becomes > > visible, > > > but once I move the child form around, the shadow is drawn behind the > > parent > > > window (and therefore not visible; none of the forms is set to be > > top-most). > > > I also tried to apply the style to the parent and the child windows, but > > it > > > won't help. > > > > > > To see this problem, simply create a project with two forms and use the > > drop > > > shadow code I posted in the Form_Load event of the first form and create a > > > button which calls the second form; then move the second form around. > > > > > > Any idea how to fix this? > > > > > > Regards, > > > Sebastian > > > > > > Are you aware that CS_DROPSHADOW requires Windows XP? If you are going to
run this code on other platforms, check the OS version first. This sample shows how to check the OS version: http://vbnet.mvps.org/index.html?code/system/getversionex.htm Link to the page that describe CS_DROPSHADOW: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windowclasses/aboutwindow.asp Quote: "CS_DROPSHADOW Windows XP: Enables the drop shadow effect on a window. The effect is turned on and off through SPI_SETDROPSHADOW. Typically, this is enabled for small, short-lived windows such as menus to emphasize their Z order relationship to other windows." Show quoteHide quote "Veign" <NOSPAMinveign@veign.com> wrote in message news:%23%23126CTwFHA.2172@TK2MSFTNGP10.phx.gbl... > Yup...Move it around, closed the parent, clicked around and the shadow > remained on Form2... > > -- > Chris Hanscom - Microsoft MVP (VB) > Veign's Resource Center > http://www.veign.com/vrc_main.asp > Veign's Blog > http://www.veign.com/blog > -- > > > "Sebastian Mares" <SebastianMa***@discussions.microsoft.com> wrote in > message news:53C92182-4B82-40B0-9B60-E69384368B48@microsoft.com... >> Weird... Did you move the second form a bit around? I just noticed that > when >> you call the second form using "Form2.Show , Me", the problem also >> appears >> when clicking on the parent form and then on the child form again > (basically >> make it lose focus and then make it gain focus again). >> >> "Veign" wrote: >> >> > Works for me... >> > >> > What I did: >> > 1) Place constants and declarations in Form1 (private) >> > 2) Made a call to the SetClassLong in Form1's load event >> > 3) Placed a command button on form1 to show form2 (Form2.Show) >> > 4) Ran the app and all worked as expected >> > >> > >> > SetClassLong (info): >> > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windowclasses/windowclassreference/windowclassfunctions/setclasslong.asp >> > >> > -- >> > Chris Hanscom - Microsoft MVP (VB) >> > Veign's Resource Center >> > http://www.veign.com/vrc_main.asp >> > Veign's Blog >> > http://www.veign.com/blog >> > -- >> > >> > >> > "Sebastian Mares" <SebastianMa***@discussions.microsoft.com> wrote in >> > message news:0DBD516C-A046-4F7E-AA75-D99DD7675585@microsoft.com... >> > > Hi there! >> > > >> > > I seem to have a problem with drawing shadows behind child forms. >> > > Here > is >> > my >> > > code: >> > > >> > > Private Const CS_DROPSHADOW As Long = &H20000 >> > > Private Const GCL_STYLE As Long = -26 >> > > >> > > Private Declare Function GetClassLong Lib "user32" Alias > "GetClassLongA" >> > > (ByVal lngHandler As Long, ByVal lngIndex As Long) As Long >> > > Private Declare Function SetClassLong Lib "user32" Alias > "SetClassLongA" >> > > (ByVal lngHandler As Long, ByVal lngIndex As Long, ByVal > lngNewClassLong >> > As >> > > Long) As Long >> > > ... >> > > SetClassLong Me.hWnd, GCL_STYLE, GetClassLong(Me.hWnd, GCL_STYLE) Or >> > > CS_DROPSHADOW >> > > ... >> > > >> > > The above source code works perfectly for the parent form, but when I > open >> > a >> > > form using >> > > >> > > frmForm.Show >> > > -or- >> > > frmForm.Show vbModal, Me >> > > -or- >> > > frmForm.Show , Me >> > > -or- >> > > frmForm.Show vbModal >> > > >> > > the shadow is drawn correctly behind the child form when it becomes >> > visible, >> > > but once I move the child form around, the shadow is drawn behind the >> > parent >> > > window (and therefore not visible; none of the forms is set to be >> > top-most). >> > > I also tried to apply the style to the parent and the child windows, > but >> > it >> > > won't help. >> > > >> > > To see this problem, simply create a project with two forms and use > the >> > drop >> > > shadow code I posted in the Form_Load event of the first form and > create a >> > > button which calls the second form; then move the second form around. >> > > >> > > Any idea how to fix this? >> > > >> > > Regards, >> > > Sebastian >> > >> > >> > > > Of course I am. Anyways, I am not performing any checks because Windows 2000
will ignore the message AFAIK. Show quoteHide quote "Someone" wrote: > Are you aware that CS_DROPSHADOW requires Windows XP? If you are going to > run this code on other platforms, check the OS version first. This sample > shows how to check the OS version: > > http://vbnet.mvps.org/index.html?code/system/getversionex.htm > > Link to the page that describe CS_DROPSHADOW: > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windowclasses/aboutwindow.asp > > Quote: "CS_DROPSHADOW Windows XP: Enables the drop shadow effect on a > window. The effect is turned on and off through SPI_SETDROPSHADOW. > Typically, this is enabled for small, short-lived windows such as menus to > emphasize their Z order relationship to other windows." > > > > > "Veign" <NOSPAMinveign@veign.com> wrote in message > news:%23%23126CTwFHA.2172@TK2MSFTNGP10.phx.gbl... > > Yup...Move it around, closed the parent, clicked around and the shadow > > remained on Form2... > > > > -- > > Chris Hanscom - Microsoft MVP (VB) > > Veign's Resource Center > > http://www.veign.com/vrc_main.asp > > Veign's Blog > > http://www.veign.com/blog > > -- > > > > > > "Sebastian Mares" <SebastianMa***@discussions.microsoft.com> wrote in > > message news:53C92182-4B82-40B0-9B60-E69384368B48@microsoft.com... > >> Weird... Did you move the second form a bit around? I just noticed that > > when > >> you call the second form using "Form2.Show , Me", the problem also > >> appears > >> when clicking on the parent form and then on the child form again > > (basically > >> make it lose focus and then make it gain focus again). > >> > >> "Veign" wrote: > >> > >> > Works for me... > >> > > >> > What I did: > >> > 1) Place constants and declarations in Form1 (private) > >> > 2) Made a call to the SetClassLong in Form1's load event > >> > 3) Placed a command button on form1 to show form2 (Form2.Show) > >> > 4) Ran the app and all worked as expected > >> > > >> > > >> > SetClassLong (info): > >> > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windowclasses/windowclassreference/windowclassfunctions/setclasslong.asp > >> > > >> > -- > >> > Chris Hanscom - Microsoft MVP (VB) > >> > Veign's Resource Center > >> > http://www.veign.com/vrc_main.asp > >> > Veign's Blog > >> > http://www.veign.com/blog > >> > -- > >> > > >> > > >> > "Sebastian Mares" <SebastianMa***@discussions.microsoft.com> wrote in > >> > message news:0DBD516C-A046-4F7E-AA75-D99DD7675585@microsoft.com... > >> > > Hi there! > >> > > > >> > > I seem to have a problem with drawing shadows behind child forms. > >> > > Here > > is > >> > my > >> > > code: > >> > > > >> > > Private Const CS_DROPSHADOW As Long = &H20000 > >> > > Private Const GCL_STYLE As Long = -26 > >> > > > >> > > Private Declare Function GetClassLong Lib "user32" Alias > > "GetClassLongA" > >> > > (ByVal lngHandler As Long, ByVal lngIndex As Long) As Long > >> > > Private Declare Function SetClassLong Lib "user32" Alias > > "SetClassLongA" > >> > > (ByVal lngHandler As Long, ByVal lngIndex As Long, ByVal > > lngNewClassLong > >> > As > >> > > Long) As Long > >> > > ... > >> > > SetClassLong Me.hWnd, GCL_STYLE, GetClassLong(Me.hWnd, GCL_STYLE) Or > >> > > CS_DROPSHADOW > >> > > ... > >> > > > >> > > The above source code works perfectly for the parent form, but when I > > open > >> > a > >> > > form using > >> > > > >> > > frmForm.Show > >> > > -or- > >> > > frmForm.Show vbModal, Me > >> > > -or- > >> > > frmForm.Show , Me > >> > > -or- > >> > > frmForm.Show vbModal > >> > > > >> > > the shadow is drawn correctly behind the child form when it becomes > >> > visible, > >> > > but once I move the child form around, the shadow is drawn behind the > >> > parent > >> > > window (and therefore not visible; none of the forms is set to be > >> > top-most). > >> > > I also tried to apply the style to the parent and the child windows, > > but > >> > it > >> > > won't help. > >> > > > >> > > To see this problem, simply create a project with two forms and use > > the > >> > drop > >> > > shadow code I posted in the Form_Load event of the first form and > > create a > >> > > button which calls the second form; then move the second form around. > >> > > > >> > > Any idea how to fix this? > >> > > > >> > > Regards, > >> > > Sebastian > >> > > >> > > >> > > > > > > > > I know and I assumed the OP did because he has it working on one form.
-- Chris Hanscom - Microsoft MVP (VB) Veign's Resource Center http://www.veign.com/vrc_main.asp Veign's Blog http://www.veign.com/blog -- "Someone" <nob***@cox.net> wrote in message news:0AhZe.50296$ct5.49204@fed1read04...> Are you aware that CS_DROPSHADOW requires Windows XP? If you are going to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windowclasses/aboutwindow.asp> run this code on other platforms, check the OS version first. This sample > shows how to check the OS version: > > http://vbnet.mvps.org/index.html?code/system/getversionex.htm > > Link to the page that describe CS_DROPSHADOW: > > Show quoteHide quote > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windowclasses/windowclassreference/windowclassfunctions/setclasslong.asp> Quote: "CS_DROPSHADOW Windows XP: Enables the drop shadow effect on a > window. The effect is turned on and off through SPI_SETDROPSHADOW. > Typically, this is enabled for small, short-lived windows such as menus to > emphasize their Z order relationship to other windows." > > > > > "Veign" <NOSPAMinveign@veign.com> wrote in message > news:%23%23126CTwFHA.2172@TK2MSFTNGP10.phx.gbl... > > Yup...Move it around, closed the parent, clicked around and the shadow > > remained on Form2... > > > > -- > > Chris Hanscom - Microsoft MVP (VB) > > Veign's Resource Center > > http://www.veign.com/vrc_main.asp > > Veign's Blog > > http://www.veign.com/blog > > -- > > > > > > "Sebastian Mares" <SebastianMa***@discussions.microsoft.com> wrote in > > message news:53C92182-4B82-40B0-9B60-E69384368B48@microsoft.com... > >> Weird... Did you move the second form a bit around? I just noticed that > > when > >> you call the second form using "Form2.Show , Me", the problem also > >> appears > >> when clicking on the parent form and then on the child form again > > (basically > >> make it lose focus and then make it gain focus again). > >> > >> "Veign" wrote: > >> > >> > Works for me... > >> > > >> > What I did: > >> > 1) Place constants and declarations in Form1 (private) > >> > 2) Made a call to the SetClassLong in Form1's load event > >> > 3) Placed a command button on form1 to show form2 (Form2.Show) > >> > 4) Ran the app and all worked as expected > >> > > >> > > >> > SetClassLong (info): > >> > > > Show quoteHide quote > >> > > >> > -- > >> > Chris Hanscom - Microsoft MVP (VB) > >> > Veign's Resource Center > >> > http://www.veign.com/vrc_main.asp > >> > Veign's Blog > >> > http://www.veign.com/blog > >> > -- > >> > > >> > > >> > "Sebastian Mares" <SebastianMa***@discussions.microsoft.com> wrote in > >> > message news:0DBD516C-A046-4F7E-AA75-D99DD7675585@microsoft.com... > >> > > Hi there! > >> > > > >> > > I seem to have a problem with drawing shadows behind child forms. > >> > > Here > > is > >> > my > >> > > code: > >> > > > >> > > Private Const CS_DROPSHADOW As Long = &H20000 > >> > > Private Const GCL_STYLE As Long = -26 > >> > > > >> > > Private Declare Function GetClassLong Lib "user32" Alias > > "GetClassLongA" > >> > > (ByVal lngHandler As Long, ByVal lngIndex As Long) As Long > >> > > Private Declare Function SetClassLong Lib "user32" Alias > > "SetClassLongA" > >> > > (ByVal lngHandler As Long, ByVal lngIndex As Long, ByVal > > lngNewClassLong > >> > As > >> > > Long) As Long > >> > > ... > >> > > SetClassLong Me.hWnd, GCL_STYLE, GetClassLong(Me.hWnd, GCL_STYLE) Or > >> > > CS_DROPSHADOW > >> > > ... > >> > > > >> > > The above source code works perfectly for the parent form, but when I > > open > >> > a > >> > > form using > >> > > > >> > > frmForm.Show > >> > > -or- > >> > > frmForm.Show vbModal, Me > >> > > -or- > >> > > frmForm.Show , Me > >> > > -or- > >> > > frmForm.Show vbModal > >> > > > >> > > the shadow is drawn correctly behind the child form when it becomes > >> > visible, > >> > > but once I move the child form around, the shadow is drawn behind the > >> > parent > >> > > window (and therefore not visible; none of the forms is set to be > >> > top-most). > >> > > I also tried to apply the style to the parent and the child windows, > > but > >> > it > >> > > won't help. > >> > > > >> > > To see this problem, simply create a project with two forms and use > > the > >> > drop > >> > > shadow code I posted in the Form_Load event of the first form and > > create a > >> > > button which calls the second form; then move the second form around. > >> > > > >> > > Any idea how to fix this? > >> > > > >> > > Regards, > >> > > Sebastian > >> > > >> > > >> > > > > > > > One last question just to be sure that you peformed the test correctly... The
child form was still over the parent form after you moved it, right? If not, please re-test and make sure that the child window remains over the parent. As mentioned already, for some reason, the shadow seems to move behind the parent on my side. However, when the form is drawn for the first time (right after the Show method), the shadow is also drawn correctly. Here is a screen shot I made to demonstrate the problem. I had Notepad behind so that the shadow can easily be seen. http://www.transilvania2000.com/www.maresweb.de/shadow.png Notice how the shadow is visible in the region where the child form is not over the parent window, while the region on the left which is over the caller form does not have a visible shadow. Show quoteHide quote "Veign" wrote: > Yup...Move it around, closed the parent, clicked around and the shadow > remained on Form2... > > -- > Chris Hanscom - Microsoft MVP (VB) > Veign's Resource Center > http://www.veign.com/vrc_main.asp > Veign's Blog > http://www.veign.com/blog > -- > > > "Sebastian Mares" <SebastianMa***@discussions.microsoft.com> wrote in > message news:53C92182-4B82-40B0-9B60-E69384368B48@microsoft.com... > > Weird... Did you move the second form a bit around? I just noticed that > when > > you call the second form using "Form2.Show , Me", the problem also appears > > when clicking on the parent form and then on the child form again > (basically > > make it lose focus and then make it gain focus again). > > > > "Veign" wrote: > > > > > Works for me... > > > > > > What I did: > > > 1) Place constants and declarations in Form1 (private) > > > 2) Made a call to the SetClassLong in Form1's load event > > > 3) Placed a command button on form1 to show form2 (Form2.Show) > > > 4) Ran the app and all worked as expected > > > > > > > > > SetClassLong (info): > > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windowclasses/windowclassreference/windowclassfunctions/setclasslong.asp > > > > > > -- > > > Chris Hanscom - Microsoft MVP (VB) > > > Veign's Resource Center > > > http://www.veign.com/vrc_main.asp > > > Veign's Blog > > > http://www.veign.com/blog > > > -- > > > > > > > > > "Sebastian Mares" <SebastianMa***@discussions.microsoft.com> wrote in > > > message news:0DBD516C-A046-4F7E-AA75-D99DD7675585@microsoft.com... > > > > Hi there! > > > > > > > > I seem to have a problem with drawing shadows behind child forms. Here > is > > > my > > > > code: > > > > > > > > Private Const CS_DROPSHADOW As Long = &H20000 > > > > Private Const GCL_STYLE As Long = -26 > > > > > > > > Private Declare Function GetClassLong Lib "user32" Alias > "GetClassLongA" > > > > (ByVal lngHandler As Long, ByVal lngIndex As Long) As Long > > > > Private Declare Function SetClassLong Lib "user32" Alias > "SetClassLongA" > > > > (ByVal lngHandler As Long, ByVal lngIndex As Long, ByVal > lngNewClassLong > > > As > > > > Long) As Long > > > > ... > > > > SetClassLong Me.hWnd, GCL_STYLE, GetClassLong(Me.hWnd, GCL_STYLE) Or > > > > CS_DROPSHADOW > > > > ... > > > > > > > > The above source code works perfectly for the parent form, but when I > open > > > a > > > > form using > > > > > > > > frmForm.Show > > > > -or- > > > > frmForm.Show vbModal, Me > > > > -or- > > > > frmForm.Show , Me > > > > -or- > > > > frmForm.Show vbModal > > > > > > > > the shadow is drawn correctly behind the child form when it becomes > > > visible, > > > > but once I move the child form around, the shadow is drawn behind the > > > parent > > > > window (and therefore not visible; none of the forms is set to be > > > top-most). > > > > I also tried to apply the style to the parent and the child windows, > but > > > it > > > > won't help. > > > > > > > > To see this problem, simply create a project with two forms and use > the > > > drop > > > > shadow code I posted in the Form_Load event of the first form and > create a > > > > button which calls the second form; then move the second form around. > > > > > > > > Any idea how to fix this? > > > > > > > > Regards, > > > > Sebastian > > > > > > > > > > > > Now I see what you are experiencing. I never really noticed that before and
feel its just a limitation of the API call against a VB applications form. Just the way VB forms work from within a single application and not something you will be able to get around. Basically it has nothing to do with a form being open from another form (what you referred to as a child form) but how all forms are loaded from a VB application - all forms are like a child form of a hidden form used by all VB applications To show and prove this create the test project and compile into an EXE. Now launch two versions of the application and note how the shadow works when you move forms ontop of forms from each instance. When the form is moved over a form that was not created by that EXE the shadow works as you would expect. You could try a test to see if it has to do with forms being loaded into the same process space by launching a form from an ActiveX EXE and one from a DLL and note what happens... -- Show quoteHide quoteChris Hanscom - Microsoft MVP (VB) Veign's Resource Center http://www.veign.com/vrc_main.asp Veign's Blog http://www.veign.com/blog -- "Sebastian Mares" <SebastianMa***@discussions.microsoft.com> wrote in http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windowclasses/windowclassreference/windowclassfunctions/setclasslong.aspmessage news:AF066F54-A655-4156-B4D9-838216B40BEF@microsoft.com... > One last question just to be sure that you peformed the test correctly... The > child form was still over the parent form after you moved it, right? If not, > please re-test and make sure that the child window remains over the parent. > As mentioned already, for some reason, the shadow seems to move behind the > parent on my side. However, when the form is drawn for the first time (right > after the Show method), the shadow is also drawn correctly. > > Here is a screen shot I made to demonstrate the problem. I had Notepad > behind so that the shadow can easily be seen. > http://www.transilvania2000.com/www.maresweb.de/shadow.png > Notice how the shadow is visible in the region where the child form is not > over the parent window, while the region on the left which is over the caller > form does not have a visible shadow. > > "Veign" wrote: > > > Yup...Move it around, closed the parent, clicked around and the shadow > > remained on Form2... > > > > -- > > Chris Hanscom - Microsoft MVP (VB) > > Veign's Resource Center > > http://www.veign.com/vrc_main.asp > > Veign's Blog > > http://www.veign.com/blog > > -- > > > > > > "Sebastian Mares" <SebastianMa***@discussions.microsoft.com> wrote in > > message news:53C92182-4B82-40B0-9B60-E69384368B48@microsoft.com... > > > Weird... Did you move the second form a bit around? I just noticed that > > when > > > you call the second form using "Form2.Show , Me", the problem also appears > > > when clicking on the parent form and then on the child form again > > (basically > > > make it lose focus and then make it gain focus again). > > > > > > "Veign" wrote: > > > > > > > Works for me... > > > > > > > > What I did: > > > > 1) Place constants and declarations in Form1 (private) > > > > 2) Made a call to the SetClassLong in Form1's load event > > > > 3) Placed a command button on form1 to show form2 (Form2.Show) > > > > 4) Ran the app and all worked as expected > > > > > > > > > > > > SetClassLong (info): > > > > > > Show quoteHide quote > > > > > > > > -- > > > > Chris Hanscom - Microsoft MVP (VB) > > > > Veign's Resource Center > > > > http://www.veign.com/vrc_main.asp > > > > Veign's Blog > > > > http://www.veign.com/blog > > > > -- > > > > > > > > > > > > "Sebastian Mares" <SebastianMa***@discussions.microsoft.com> wrote in > > > > message news:0DBD516C-A046-4F7E-AA75-D99DD7675585@microsoft.com... > > > > > Hi there! > > > > > > > > > > I seem to have a problem with drawing shadows behind child forms. Here > > is > > > > my > > > > > code: > > > > > > > > > > Private Const CS_DROPSHADOW As Long = &H20000 > > > > > Private Const GCL_STYLE As Long = -26 > > > > > > > > > > Private Declare Function GetClassLong Lib "user32" Alias > > "GetClassLongA" > > > > > (ByVal lngHandler As Long, ByVal lngIndex As Long) As Long > > > > > Private Declare Function SetClassLong Lib "user32" Alias > > "SetClassLongA" > > > > > (ByVal lngHandler As Long, ByVal lngIndex As Long, ByVal > > lngNewClassLong > > > > As > > > > > Long) As Long > > > > > ... > > > > > SetClassLong Me.hWnd, GCL_STYLE, GetClassLong(Me.hWnd, GCL_STYLE) Or > > > > > CS_DROPSHADOW > > > > > ... > > > > > > > > > > The above source code works perfectly for the parent form, but when I > > open > > > > a > > > > > form using > > > > > > > > > > frmForm.Show > > > > > -or- > > > > > frmForm.Show vbModal, Me > > > > > -or- > > > > > frmForm.Show , Me > > > > > -or- > > > > > frmForm.Show vbModal > > > > > > > > > > the shadow is drawn correctly behind the child form when it becomes > > > > visible, > > > > > but once I move the child form around, the shadow is drawn behind the > > > > parent > > > > > window (and therefore not visible; none of the forms is set to be > > > > top-most). > > > > > I also tried to apply the style to the parent and the child windows, > > but > > > > it > > > > > won't help. > > > > > > > > > > To see this problem, simply create a project with two forms and use > > the > > > > drop > > > > > shadow code I posted in the Form_Load event of the first form and > > create a > > > > > button which calls the second form; then move the second form around. > > > > > > > > > > Any idea how to fix this? > > > > > > > > > > Regards, > > > > > Sebastian > > > > > > > > > > > > > > > > > > The OP could also try setting ownership of the form to the desktop
(SetWindowLong and the GWL_HWNDPARENT value) which appears to work here. As always, one should set ownership back to the original owner before the form is destroyed to avoid "complications". HTH, Bryan ____________________________________________________________ New Vision Software "When the going gets weird," Bryan Stafford "the weird turn pro." alpine_don'tsendspam@mvps.org Hunter S. Thompson - Microsoft MVP-Visual Basic Fear and Loathing in LasVegas Show quoteHide quote On Sat, 24 Sep 2005 18:27:16 -0400, "Veign" <NOSPAMinveign@veign.com> wrote: >Now I see what you are experiencing. I never really noticed that before and >feel its just a limitation of the API call against a VB applications form. >Just the way VB forms work from within a single application and not >something you will be able to get around. > >Basically it has nothing to do with a form being open from another form >(what you referred to as a child form) but how all forms are loaded from a >VB application - all forms are like a child form of a hidden form used by >all VB applications > >To show and prove this create the test project and compile into an EXE. Now >launch two versions of the application and note how the shadow works when >you move forms ontop of forms from each instance. When the form is moved >over a form that was not created by that EXE the shadow works as you would >expect. > >You could try a test to see if it has to do with forms being loaded into the >same process space by launching a form from an ActiveX EXE and one from a >DLL and note what happens... > >-- >Chris Hanscom - Microsoft MVP (VB) >Veign's Resource Center >http://www.veign.com/vrc_main.asp >Veign's Blog >http://www.veign.com/blog Good idea.
Me thinks this will give an effect not common in other applications that use the shadow effect. Meaning, doesn't seem to be a problem if this is this how other applications (including Windows) would implement the effect. -- Show quoteHide quoteChris Hanscom - Microsoft MVP (VB) Veign's Resource Center http://www.veign.com/vrc_main.asp Veign's Blog http://www.veign.com/blog -- "alpine" <alpine_don'tsendspam@mvps.org> wrote in message news:mfmbj1l5a21krrmd7c9fd8jkih5c3gs2ft@4ax.com... > The OP could also try setting ownership of the form to the desktop > (SetWindowLong and the GWL_HWNDPARENT value) which appears to work > here. As always, one should set ownership back to the original owner > before the form is destroyed to avoid "complications". > > HTH, > Bryan > ____________________________________________________________ > New Vision Software "When the going gets weird," > Bryan Stafford "the weird turn pro." > alpine_don'tsendspam@mvps.org Hunter S. Thompson - > Microsoft MVP-Visual Basic Fear and Loathing in LasVegas > > > On Sat, 24 Sep 2005 18:27:16 -0400, "Veign" <NOSPAMinveign@veign.com> > wrote: > > >Now I see what you are experiencing. I never really noticed that before and > >feel its just a limitation of the API call against a VB applications form. > >Just the way VB forms work from within a single application and not > >something you will be able to get around. > > > >Basically it has nothing to do with a form being open from another form > >(what you referred to as a child form) but how all forms are loaded from a > >VB application - all forms are like a child form of a hidden form used by > >all VB applications > > > >To show and prove this create the test project and compile into an EXE. Now > >launch two versions of the application and note how the shadow works when > >you move forms ontop of forms from each instance. When the form is moved > >over a form that was not created by that EXE the shadow works as you would > >expect. > > > >You could try a test to see if it has to do with forms being loaded into the > >same process space by launching a form from an ActiveX EXE and one from a > >DLL and note what happens... > > > >-- > >Chris Hanscom - Microsoft MVP (VB) > >Veign's Resource Center > >http://www.veign.com/vrc_main.asp > >Veign's Blog > >http://www.veign.com/blog > Hmm, not sure if I did it correctly since it doesn't work... This is what I
used in the second form: SetWindowLong Me.hwnd, GWL_HWNDPARENT, GetDesktopWindow Show quoteHide quote "alpine" wrote: > The OP could also try setting ownership of the form to the desktop > (SetWindowLong and the GWL_HWNDPARENT value) which appears to work > here. As always, one should set ownership back to the original owner > before the form is destroyed to avoid "complications". > > HTH, > Bryan > ____________________________________________________________ > New Vision Software "When the going gets weird," > Bryan Stafford "the weird turn pro." > alpine_don'tsendspam@mvps.org Hunter S. Thompson - > Microsoft MVP-Visual Basic Fear and Loathing in LasVegas > > > On Sat, 24 Sep 2005 18:27:16 -0400, "Veign" <NOSPAMinveign@veign.com> > wrote: > > >Now I see what you are experiencing. I never really noticed that before and > >feel its just a limitation of the API call against a VB applications form. > >Just the way VB forms work from within a single application and not > >something you will be able to get around. > > > >Basically it has nothing to do with a form being open from another form > >(what you referred to as a child form) but how all forms are loaded from a > >VB application - all forms are like a child form of a hidden form used by > >all VB applications > > > >To show and prove this create the test project and compile into an EXE. Now > >launch two versions of the application and note how the shadow works when > >you move forms ontop of forms from each instance. When the form is moved > >over a form that was not created by that EXE the shadow works as you would > >expect. > > > >You could try a test to see if it has to do with forms being loaded into the > >same process space by launching a form from an ActiveX EXE and one from a > >DLL and note what happens... > > > >-- > >Chris Hanscom - Microsoft MVP (VB) > >Veign's Resource Center > >http://www.veign.com/vrc_main.asp > >Veign's Blog > >http://www.veign.com/blog > > Works perfectly here. Create a new project and paste the code below
into the form for which you wish to display a drop shadow. HTH, Bryan ____________________________________________________________ New Vision Software "When the going gets weird," Bryan Stafford "the weird turn pro." alpine_don'tsendspam@mvps.org Hunter S. Thompson - Microsoft MVP-Visual Basic Fear and Loathing in LasVegas Option Explicit Private m_hOriginalParent As Long Private Const GWL_HWNDPARENT As Long = (-8) Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Const CS_DROPSHADOW As Long = &H20000 Private Const GCL_STYLE As Long = -26 Private Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" (ByVal lngHandler As Long, ByVal lngIndex As Long) As Long Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" (ByVal lngHandler As Long, ByVal lngIndex As Long, ByVal lngNewClassLong As Long) As Long Private Declare Function GetDesktopWindow Lib "user32" () As Long Private Sub Form_Load() m_hOriginalParent = SetWindowLong(hWnd, GWL_HWNDPARENT, GetDesktopWindow()) Call SetClassLong(hWnd, GCL_STYLE, GetClassLong(Me.hWnd, GCL_STYLE) Or CS_DROPSHADOW) End Sub Private Sub Form_Unload(Cancel As Integer) Call SetWindowLong(hWnd, GWL_HWNDPARENT, m_hOriginalParent) End Sub On Sun, 25 Sep 2005 00:15:02 -0700, Sebastian Mares <SebastianMa***@discussions.microsoft.com> wrote: Show quoteHide quote >Hmm, not sure if I did it correctly since it doesn't work... This is what I >used in the second form: > >SetWindowLong Me.hwnd, GWL_HWNDPARENT, GetDesktopWindow > >"alpine" wrote: > >> The OP could also try setting ownership of the form to the desktop >> (SetWindowLong and the GWL_HWNDPARENT value) which appears to work >> here. As always, one should set ownership back to the original owner >> before the form is destroyed to avoid "complications". >> >> HTH, >> Bryan >> ____________________________________________________________ >> New Vision Software "When the going gets weird," >> Bryan Stafford "the weird turn pro." >> alpine_don'tsendspam@mvps.org Hunter S. Thompson - >> Microsoft MVP-Visual Basic Fear and Loathing in LasVegas >> >> >> On Sat, 24 Sep 2005 18:27:16 -0400, "Veign" <NOSPAMinveign@veign.com> >> wrote: >> >> >Now I see what you are experiencing. I never really noticed that before and >> >feel its just a limitation of the API call against a VB applications form. >> >Just the way VB forms work from within a single application and not >> >something you will be able to get around. >> > >> >Basically it has nothing to do with a form being open from another form >> >(what you referred to as a child form) but how all forms are loaded from a >> >VB application - all forms are like a child form of a hidden form used by >> >all VB applications >> > >> >To show and prove this create the test project and compile into an EXE. Now >> >launch two versions of the application and note how the shadow works when >> >you move forms ontop of forms from each instance. When the form is moved >> >over a form that was not created by that EXE the shadow works as you would >> >expect. >> > >> >You could try a test to see if it has to do with forms being loaded into the >> >same process space by launching a form from an ActiveX EXE and one from a >> >DLL and note what happens... >> > >> >-- >> >Chris Hanscom - Microsoft MVP (VB) >> >Veign's Resource Center >> >http://www.veign.com/vrc_main.asp >> >Veign's Blog >> >http://www.veign.com/blog >> >> Nope, doesn't work for me. I placed the code in both forms and this is the
result: http://www.transilvania2000.com/www.maresweb.de/shadow2.png PS: I am running the compiled application (not in the IDE). Show quoteHide quote "alpine" wrote: > Works perfectly here. Create a new project and paste the code below > into the form for which you wish to display a drop shadow. > > HTH, > Bryan > ____________________________________________________________ > New Vision Software "When the going gets weird," > Bryan Stafford "the weird turn pro." > alpine_don'tsendspam@mvps.org Hunter S. Thompson - > Microsoft MVP-Visual Basic Fear and Loathing in LasVegas > > > Option Explicit > > Private m_hOriginalParent As Long > > Private Const GWL_HWNDPARENT As Long = (-8) > > Private Declare Function GetWindowLong Lib "user32" Alias > "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long > Private Declare Function SetWindowLong Lib "user32" Alias > "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal > dwNewLong As Long) As Long > > Private Const CS_DROPSHADOW As Long = &H20000 > Private Const GCL_STYLE As Long = -26 > > Private Declare Function GetClassLong Lib "user32" Alias > "GetClassLongA" (ByVal lngHandler As Long, ByVal lngIndex As Long) As > Long > Private Declare Function SetClassLong Lib "user32" Alias > "SetClassLongA" (ByVal lngHandler As Long, ByVal lngIndex As Long, > ByVal lngNewClassLong As Long) As Long > > Private Declare Function GetDesktopWindow Lib "user32" () As Long > > Private Sub Form_Load() > > m_hOriginalParent = SetWindowLong(hWnd, GWL_HWNDPARENT, > GetDesktopWindow()) > > Call SetClassLong(hWnd, GCL_STYLE, GetClassLong(Me.hWnd, GCL_STYLE) > Or CS_DROPSHADOW) > > End Sub > > Private Sub Form_Unload(Cancel As Integer) > > Call SetWindowLong(hWnd, GWL_HWNDPARENT, m_hOriginalParent) > > End Sub > > > > > On Sun, 25 Sep 2005 00:15:02 -0700, Sebastian Mares > <SebastianMa***@discussions.microsoft.com> wrote: > > >Hmm, not sure if I did it correctly since it doesn't work... This is what I > >used in the second form: > > > >SetWindowLong Me.hwnd, GWL_HWNDPARENT, GetDesktopWindow > > > >"alpine" wrote: > > > >> The OP could also try setting ownership of the form to the desktop > >> (SetWindowLong and the GWL_HWNDPARENT value) which appears to work > >> here. As always, one should set ownership back to the original owner > >> before the form is destroyed to avoid "complications". > >> > >> HTH, > >> Bryan > >> ____________________________________________________________ > >> New Vision Software "When the going gets weird," > >> Bryan Stafford "the weird turn pro." > >> alpine_don'tsendspam@mvps.org Hunter S. Thompson - > >> Microsoft MVP-Visual Basic Fear and Loathing in LasVegas > >> > >> > >> On Sat, 24 Sep 2005 18:27:16 -0400, "Veign" <NOSPAMinveign@veign.com> > >> wrote: > >> > >> >Now I see what you are experiencing. I never really noticed that before and > >> >feel its just a limitation of the API call against a VB applications form. > >> >Just the way VB forms work from within a single application and not > >> >something you will be able to get around. > >> > > >> >Basically it has nothing to do with a form being open from another form > >> >(what you referred to as a child form) but how all forms are loaded from a > >> >VB application - all forms are like a child form of a hidden form used by > >> >all VB applications > >> > > >> >To show and prove this create the test project and compile into an EXE. Now > >> >launch two versions of the application and note how the shadow works when > >> >you move forms ontop of forms from each instance. When the form is moved > >> >over a form that was not created by that EXE the shadow works as you would > >> >expect. > >> > > >> >You could try a test to see if it has to do with forms being loaded into the > >> >same process space by launching a form from an ActiveX EXE and one from a > >> >DLL and note what happens... > >> > > >> >-- > >> >Chris Hanscom - Microsoft MVP (VB) > >> >Veign's Resource Center > >> >http://www.veign.com/vrc_main.asp > >> >Veign's Blog > >> >http://www.veign.com/blog > >> > >> > > I am also running a compiled app and have tested both VB5 and VB6 code
with no problems. The test OS is WinXP Pro, SP2 Bryan ____________________________________________________________ New Vision Software "When the going gets weird," Bryan Stafford "the weird turn pro." alpine_don'tsendspam@mvps.org Hunter S. Thompson - Microsoft MVP-Visual Basic Fear and Loathing in LasVegas On Sun, 25 Sep 2005 01:46:01 -0700, Sebastian Mares <SebastianMa***@discussions.microsoft.com> wrote: Show quoteHide quote >Nope, doesn't work for me. I placed the code in both forms and this is the >result: > >http://www.transilvania2000.com/www.maresweb.de/shadow2.png > >PS: I am running the compiled application (not in the IDE). > >"alpine" wrote: > >> Works perfectly here. Create a new project and paste the code below >> into the form for which you wish to display a drop shadow. >> >> HTH, >> Bryan >> ____________________________________________________________ >> New Vision Software "When the going gets weird," >> Bryan Stafford "the weird turn pro." >> alpine_don'tsendspam@mvps.org Hunter S. Thompson - >> Microsoft MVP-Visual Basic Fear and Loathing in LasVegas >> >> >> Option Explicit >> >> Private m_hOriginalParent As Long >> >> Private Const GWL_HWNDPARENT As Long = (-8) >> >> Private Declare Function GetWindowLong Lib "user32" Alias >> "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long >> Private Declare Function SetWindowLong Lib "user32" Alias >> "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal >> dwNewLong As Long) As Long >> >> Private Const CS_DROPSHADOW As Long = &H20000 >> Private Const GCL_STYLE As Long = -26 >> >> Private Declare Function GetClassLong Lib "user32" Alias >> "GetClassLongA" (ByVal lngHandler As Long, ByVal lngIndex As Long) As >> Long >> Private Declare Function SetClassLong Lib "user32" Alias >> "SetClassLongA" (ByVal lngHandler As Long, ByVal lngIndex As Long, >> ByVal lngNewClassLong As Long) As Long >> >> Private Declare Function GetDesktopWindow Lib "user32" () As Long >> >> Private Sub Form_Load() >> >> m_hOriginalParent = SetWindowLong(hWnd, GWL_HWNDPARENT, >> GetDesktopWindow()) >> >> Call SetClassLong(hWnd, GCL_STYLE, GetClassLong(Me.hWnd, GCL_STYLE) >> Or CS_DROPSHADOW) >> >> End Sub >> >> Private Sub Form_Unload(Cancel As Integer) >> >> Call SetWindowLong(hWnd, GWL_HWNDPARENT, m_hOriginalParent) >> >> End Sub >> >> >> >> >> On Sun, 25 Sep 2005 00:15:02 -0700, Sebastian Mares >> <SebastianMa***@discussions.microsoft.com> wrote: >> >> >Hmm, not sure if I did it correctly since it doesn't work... This is what I >> >used in the second form: >> > >> >SetWindowLong Me.hwnd, GWL_HWNDPARENT, GetDesktopWindow >> > >> >"alpine" wrote: >> > >> >> The OP could also try setting ownership of the form to the desktop >> >> (SetWindowLong and the GWL_HWNDPARENT value) which appears to work >> >> here. As always, one should set ownership back to the original owner >> >> before the form is destroyed to avoid "complications". >> >> >> >> HTH, >> >> Bryan >> >> ____________________________________________________________ >> >> New Vision Software "When the going gets weird," >> >> Bryan Stafford "the weird turn pro." >> >> alpine_don'tsendspam@mvps.org Hunter S. Thompson - >> >> Microsoft MVP-Visual Basic Fear and Loathing in LasVegas >> >> >> >> >> >> On Sat, 24 Sep 2005 18:27:16 -0400, "Veign" <NOSPAMinveign@veign.com> >> >> wrote: >> >> >> >> >Now I see what you are experiencing. I never really noticed that before and >> >> >feel its just a limitation of the API call against a VB applications form. >> >> >Just the way VB forms work from within a single application and not >> >> >something you will be able to get around. >> >> > >> >> >Basically it has nothing to do with a form being open from another form >> >> >(what you referred to as a child form) but how all forms are loaded from a >> >> >VB application - all forms are like a child form of a hidden form used by >> >> >all VB applications >> >> > >> >> >To show and prove this create the test project and compile into an EXE. Now >> >> >launch two versions of the application and note how the shadow works when >> >> >you move forms ontop of forms from each instance. When the form is moved >> >> >over a form that was not created by that EXE the shadow works as you would >> >> >expect. >> >> > >> >> >You could try a test to see if it has to do with forms being loaded into the >> >> >same process space by launching a form from an ActiveX EXE and one from a >> >> >DLL and note what happens... >> >> > >> >> >-- >> >> >Chris Hanscom - Microsoft MVP (VB) >> >> >Veign's Resource Center >> >> >http://www.veign.com/vrc_main.asp >> >> >Veign's Blog >> >> >http://www.veign.com/blog >> >> >> >> >> >> Oh well, I'll leave it as-is then since it's not my fault.
Show quoteHide quote "alpine" wrote: > I am also running a compiled app and have tested both VB5 and VB6 code > with no problems. The test OS is WinXP Pro, SP2 > > Bryan > ____________________________________________________________ > New Vision Software "When the going gets weird," > Bryan Stafford "the weird turn pro." > alpine_don'tsendspam@mvps.org Hunter S. Thompson - > Microsoft MVP-Visual Basic Fear and Loathing in LasVegas > > > On Sun, 25 Sep 2005 01:46:01 -0700, Sebastian Mares > <SebastianMa***@discussions.microsoft.com> wrote: > > >Nope, doesn't work for me. I placed the code in both forms and this is the > >result: > > > >http://www.transilvania2000.com/www.maresweb.de/shadow2.png > > > >PS: I am running the compiled application (not in the IDE). > > > >"alpine" wrote: > > > >> Works perfectly here. Create a new project and paste the code below > >> into the form for which you wish to display a drop shadow. > >> > >> HTH, > >> Bryan > >> ____________________________________________________________ > >> New Vision Software "When the going gets weird," > >> Bryan Stafford "the weird turn pro." > >> alpine_don'tsendspam@mvps.org Hunter S. Thompson - > >> Microsoft MVP-Visual Basic Fear and Loathing in LasVegas > >> > >> > >> Option Explicit > >> > >> Private m_hOriginalParent As Long > >> > >> Private Const GWL_HWNDPARENT As Long = (-8) > >> > >> Private Declare Function GetWindowLong Lib "user32" Alias > >> "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long > >> Private Declare Function SetWindowLong Lib "user32" Alias > >> "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal > >> dwNewLong As Long) As Long > >> > >> Private Const CS_DROPSHADOW As Long = &H20000 > >> Private Const GCL_STYLE As Long = -26 > >> > >> Private Declare Function GetClassLong Lib "user32" Alias > >> "GetClassLongA" (ByVal lngHandler As Long, ByVal lngIndex As Long) As > >> Long > >> Private Declare Function SetClassLong Lib "user32" Alias > >> "SetClassLongA" (ByVal lngHandler As Long, ByVal lngIndex As Long, > >> ByVal lngNewClassLong As Long) As Long > >> > >> Private Declare Function GetDesktopWindow Lib "user32" () As Long > >> > >> Private Sub Form_Load() > >> > >> m_hOriginalParent = SetWindowLong(hWnd, GWL_HWNDPARENT, > >> GetDesktopWindow()) > >> > >> Call SetClassLong(hWnd, GCL_STYLE, GetClassLong(Me.hWnd, GCL_STYLE) > >> Or CS_DROPSHADOW) > >> > >> End Sub > >> > >> Private Sub Form_Unload(Cancel As Integer) > >> > >> Call SetWindowLong(hWnd, GWL_HWNDPARENT, m_hOriginalParent) > >> > >> End Sub > >> > >> > >> > >> > >> On Sun, 25 Sep 2005 00:15:02 -0700, Sebastian Mares > >> <SebastianMa***@discussions.microsoft.com> wrote: > >> > >> >Hmm, not sure if I did it correctly since it doesn't work... This is what I > >> >used in the second form: > >> > > >> >SetWindowLong Me.hwnd, GWL_HWNDPARENT, GetDesktopWindow > >> > > >> >"alpine" wrote: > >> > > >> >> The OP could also try setting ownership of the form to the desktop > >> >> (SetWindowLong and the GWL_HWNDPARENT value) which appears to work > >> >> here. As always, one should set ownership back to the original owner > >> >> before the form is destroyed to avoid "complications". > >> >> > >> >> HTH, > >> >> Bryan > >> >> ____________________________________________________________ > >> >> New Vision Software "When the going gets weird," > >> >> Bryan Stafford "the weird turn pro." > >> >> alpine_don'tsendspam@mvps.org Hunter S. Thompson - > >> >> Microsoft MVP-Visual Basic Fear and Loathing in LasVegas > >> >> > >> >> > >> >> On Sat, 24 Sep 2005 18:27:16 -0400, "Veign" <NOSPAMinveign@veign.com> > >> >> wrote: > >> >> > >> >> >Now I see what you are experiencing. I never really noticed that before and > >> >> >feel its just a limitation of the API call against a VB applications form. > >> >> >Just the way VB forms work from within a single application and not > >> >> >something you will be able to get around. > >> >> > > >> >> >Basically it has nothing to do with a form being open from another form > >> >> >(what you referred to as a child form) but how all forms are loaded from a > >> >> >VB application - all forms are like a child form of a hidden form used by > >> >> >all VB applications > >> >> > > >> >> >To show and prove this create the test project and compile into an EXE. Now > >> >> >launch two versions of the application and note how the shadow works when > >> >> >you move forms ontop of forms from each instance. When the form is moved > >> >> >over a form that was not created by that EXE the shadow works as you would > >> >> >expect. > >> >> > > >> >> >You could try a test to see if it has to do with forms being loaded into the > >> >> >same process space by launching a form from an ActiveX EXE and one from a > >> >> >DLL and note what happens... > >> >> > > >> >> >-- > >> >> >Chris Hanscom - Microsoft MVP (VB) > >> >> >Veign's Resource Center > >> >> >http://www.veign.com/vrc_main.asp > >> >> >Veign's Blog > >> >> >http://www.veign.com/blog > >> >> > >> >> > >> > >> > > On Sun, 25 Sep 2005 02:24:52 -0600, alpine
<alpine_don'tsendspam@mvps.org> wrote: Show quoteHide quote >Works perfectly here. Create a new project and paste the code below FWIW:>into the form for which you wish to display a drop shadow. > >HTH, >Bryan >____________________________________________________________ >New Vision Software "When the going gets weird," >Bryan Stafford "the weird turn pro." >alpine_don'tsendspam@mvps.org Hunter S. Thompson - >Microsoft MVP-Visual Basic Fear and Loathing in LasVegas > > > Option Explicit > > Private m_hOriginalParent As Long > > Private Const GWL_HWNDPARENT As Long = (-8) > > Private Declare Function GetWindowLong Lib "user32" Alias >"GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long > Private Declare Function SetWindowLong Lib "user32" Alias >"SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal >dwNewLong As Long) As Long > > Private Const CS_DROPSHADOW As Long = &H20000 > Private Const GCL_STYLE As Long = -26 > > Private Declare Function GetClassLong Lib "user32" Alias >"GetClassLongA" (ByVal lngHandler As Long, ByVal lngIndex As Long) As >Long > Private Declare Function SetClassLong Lib "user32" Alias >"SetClassLongA" (ByVal lngHandler As Long, ByVal lngIndex As Long, >ByVal lngNewClassLong As Long) As Long > > Private Declare Function GetDesktopWindow Lib "user32" () As Long > >Private Sub Form_Load() > > m_hOriginalParent = SetWindowLong(hWnd, GWL_HWNDPARENT, >GetDesktopWindow()) > > Call SetClassLong(hWnd, GCL_STYLE, GetClassLong(Me.hWnd, GCL_STYLE) >Or CS_DROPSHADOW) > >End Sub > >Private Sub Form_Unload(Cancel As Integer) > > Call SetWindowLong(hWnd, GWL_HWNDPARENT, m_hOriginalParent) > >End Sub > > Played around with shadows a few months ago. 1) In your example, any additional forms added and loaded while Form1 is loaded will have a shadow which may or may not be desired. 2) In your example, if you add a main form as a startup form and preload Form1, the main form will have a shadow which is usually not desired. In my case, I was only interested in adding a shadow to a few custom dialogs and custom message box. From what I was able to determine, in addition to the above code, MSDN indicates that you control which forms are to be shadowed when shown with, for example: SystemParametersInfo SPI_SETDROPSHADOW, 0, vbFalse, 0 frmMain.Show SystemParametersInfo SPI_SETDROPSHADOW, 0, vbTrue, 0 frmBrowse.Show vbModal, frmMain SystemParametersInfo SPI_SETDROPSHADOW, 0, vbFalse, 0 The above works as expected, but introduces another issue. When setting the system shadow to false and the user activates another app, the system shadow setting may or may not correspond to the user's shadow setting. Therefore, you have to: 1) Determine, on startup, the user's shadow setting. 2) Sub-class the main form to determine when this app is active/inactive and restore the user setting if necessary. 3) Restore the user setting (if necessary) when this app is closed. Gene |
|||||||||||||||||||||||