PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Marc van Cauwenberghe on April 07, 2010, 10:08:14 AM

Title: Some input please
Post by: Marc van Cauwenberghe on April 07, 2010, 10:08:14 AM
Hello,
I would like to have some input on a small part of code:

Function FRMPOPUPOBSERVER_WM_CREATE (hWndForm As Dword, ByVal UserData As Long) As Long
   Local rc As Rect
   If GetParent(HWND_FRMPOPUPOBSERVER) = HWND_FRMEDITSESSION Then
      FF_Control_SetSize( HWND_FRMPOPUPOBSERVER, 230, 215 )
      FF_Control_SetSize( HWND_FRMPOPUPOBSERVER_EGOBSERVER, 217, 200 )   
      Dim lWindowStyle As Long
      lWindowStyle = GetWindowLong(hWndForm, %GWL_STYLE)     
      lWindowStyle = lWindowStyle And (Not %WS_CAPTION Or %WS_BORDER) ' turn off caption     
      SetWindowLong hWndForm, %GWL_STYLE, lWindowStyle ' and reset the window
      GetWindowRect HWND_FRMEDITSESSION, rc ' Get the screen coordinates of the control
      SetWindowPos HWND_FRMPOPUPOBSERVER, 0, rc.nLeft + 280, rc.nTop + 45, 0, 0, %SWP_NOSIZE Or %SWP_SHOWWINDOW         
   Else
      GetWindowRect g_tCP.lPlace, rc ' Get the screen coordinates of the control
      SetWindowPos HWND_FRMPOPUPOBSERVER, 0, rc.nRight, rc.nTop, 0, 0, %SWP_NOSIZE Or %SWP_SHOWWINDOW       
   End If
   
   EG_SetGridCursor( HWND_FRMPOPUPOBSERVER_EGOBSERVER )   
   Call FillPopUpObserverForm()
End Function


What am I trying to do:
I am showing a popup form when clicking on a field.
The popup form gets used in 2 other (parent)forms

In one (parent)form I want a real popup dialog (the one I have designed)
In another form I want a more embedden dialog.
I wrote the code to make an embeded dialog in run time and it seems to work.
Have any of you any comments on the method I am using.

Thanks,
Marc

Title: Re: Some input please
Post by: Marc van Cauwenberghe on April 10, 2010, 07:34:54 AM
Anybody?  :( :( :(
Title: Re: Some input please
Post by: Paul Squires on April 10, 2010, 01:34:39 PM
Hi Marc,

Looks good to me, especially if it is working for you!  :)

I do something similar in one of my apps. I create the "reusable" form as a generic form with no borders or anything - much like a TabControlChildform. It has the WS_CHILD style set of course. I then use SetParent to place that form with whatever parent form that I want to use it with. I don't see you using SetParent anywhere though....
Title: Re: Some input please
Post by: James Fuller on April 10, 2010, 04:49:27 PM
This is probably not relevant but....
http://blogs.msdn.com/oldnewthing/archive/2010/03/16/9979112.aspx

James
Title: Re: Some input please
Post by: Marc van Cauwenberghe on April 11, 2010, 04:20:11 AM
Thank you Paul. It is just that usind 4 direct api calls in one function is a milestone for me.  :D
Do not think I need SetParent because the popup window is called from 2 different parent windows or am I missing a point here?
Thank you also James, I bookmarked the link for reference.

Marc

Title: Re: Some input please
Post by: Paul Squires on April 11, 2010, 10:24:27 AM
Quote from: Marc van Cauwenberghe on April 11, 2010, 04:20:11 AM
Do not think I need SetParent because the popup window is called from 2 different parent windows or am I missing a point here?

Yes, you're right. If you are loading the child window modeless for each of the two different parent windows then you're okay. In my case, I load the child window once at program start and need to "reassign" it to different parent windows over the life of the application.