child picture

Started by paulDiagnos, January 03, 2006, 08:39:40 AM

Previous topic - Next topic

paulDiagnos

Hi all,

I am trying to solve a problem that im sure has a really easy and obvious solution...

I have created a simple form with firefly, on the form is a picturebox ( with no picture in it)

i then have created a dll, this creates a child window.  with a few lines and colours on jsut for testing.

i then can load the window from the dll onto my picture box no problem and i can see the lines and colours created for test this is all fine.

my problem is keeping it there. if i minamize and then view again then the dll window has dissapeard. bummer.

any way to solve this problem not sure if its at the dll end of the firefly end

thanks in advance Paul

TechSupport

I am not 100% sure I understand what it is you are doing. You are trying to load a Form from a DLL into a Picture Box control that is located on a Form in the main FireFly application ? Are you trying to simply draw graphics on the Picture Box? If so, there is an easier way to accomplish your task.

You do not need to create a Form in your DLL project. You could simply send the handle of the Picture Box control to a painting procedure in the DLL whenever the Picture Box's WM_PAINT message fires. For example:


Function FORM1_PICTURE1_WM_PAINT ( _
                                ControlIndex  As Long,  _  ' index in Control Array
                                hWndForm      As Dword, _  ' handle of Form
                                hWndControl   As Dword  _  ' handle of Control
                                ) As Long

  ' Handle the painting of the Picture Box in a routine located in the DLL
  ' The function name could be whatever you wish.  
  DLL_Draw hWndControl

  function = %TRUE: exit function

End Function


In your DLL the code would look something liek the following:

Function DLL_Draw( byval hWndControl as dword) As Long Export
 
  Local rc    as Rect
  Local hDC as DWord

  GetClientRect hWndControl, rc
 
  ' Get the DC and do the painting
  hDC = GetDC( hWndcontrol )

  ' do your drawing here.... rc outlines the area to draw in.

  ReleaseDC hWndControl, hDC

end function


The above is off the top of my head but it should work.

If that does not work then you can try explaining what it is you are trying to do and I will try to come up with a better solution.

paulDiagnos

ok yes im not too good at explaining il give another go ...

The reason I need to have the dll is so that I dont have 100's of forms. this is just actually stepping stone for me, i want to be able to pass the dll a text file with some sort of script. then the dll will use the file to create a form adding buttons and things where nessesary so i can have many pages on a form.

its quite hard for me to descibe and is probably why searching forums itsnt helping me.

you have a form created with firefly where most of the action happens. you pass a dll a set of paramaters including the handle of the picture window, and it loads up a kinda mask or over lay over the picture. now all messages are passed to the child ( the dll window ) , buttons can be added and taken away and text etc. thus have a page. then if i want to get rid of the page i can then load another set of params.

the problem im having is the child window doesnt seem to always show. it disapears.

i hope this describes it better. thanks for your patients my grasp of english hasnt managed to cling on yet

TechSupport

Maybe you need to set the WS_CHILD property of the Form that is in the DLL. When you display the DLL Form you will probably need to specify the PictureBox's window handle as the parent form. You should also display it modeless.

frmDLLform_Show HWND_FORM1_PICTUREBOX1, %FALSE

Just to safe, you should ensure that the zorder of the DLL Form is set to the top to ensure that it displays on top of the PictureBox.

SetWindowPos HWND_FORM1_PICTUREBOX1, %HWND_TOP, 0, 0, 0, 0, %SWP_NOSIZE Or %SWP_NOMOVE

paulDiagnos

brilliant thanks for that,

that worked great, causing some redraw issues so needed to have the callback paint and then redraw

thanks for your help