Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GdiPLusX Drawing on a form with scrollbars
Message
De
15/12/2007 17:48:29
 
 
À
15/12/2007 17:34:03
Information générale
Forum:
Visual FoxPro
Catégorie:
VFPX/Sedna
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP1
Divers
Thread ID:
01276096
Message ID:
01276115
Vues:
31
This message has been marked as a message which has helped to the initial question of the thread.
>>>>Dear All,
>>>>
>>>>Is there any way to draw directly to a form surface
>>>>with form scrollbars enabled ?
>>>>
>>>>TIA
>>>>Sergio
>>>
>>>
>>>Hi Sergio,
>>>
>>>That's totally possible, why not ?
>>>Are you trying to draw in a topLevel form ?
>>>If yes, there's a small trick to obtain the surface HWND:
>>>
>>>
LOCAL lnHWnd
>>>IF Thisform.ShowWindow = 2 && TopLevel Form
>>>	lnHWnd=SYS(2327, SYS(2325, SYS(2326,Thisform.HWnd))) && From Craig Boyd
>>>ELSE
>>>	lnHWnd = Thisform.HWnd
>>>ENDIF
>>>
>>>Is this what you are looking for ?
>>
>>
>>Hi Cesar,
>>
>>I am trying to draw on ordinary modeless form.
>>ShowWindow is by default 0 (In Screen)
>>
>>Without scrollbars everything shows just fine
>>as soon I enable toolbars - nothing shows :(
>>
>>Maybe never version of GdiPlusX ?
>>This one I am working with I downloaded about month ago
>>(Forgot number)
>>
>>TIA
>
>
>Hi Sregio,
>
>This has nothing to do with the version of Gdi+X
>
>I've tried here, and you are correct... This is totally strange...
>
>But I made it work. The solution is really tricky, but seems to be reliable:
>
>
>My conclusion is that when the form has a ScrollBar, a new window is added to it, and this makes a big confusion. The original solution I gave you would not work because it was getting the HWND from the ScrollBars !
>
>For this situation, VFP adds the ScrollBars after the INIT() event is fired, so you can't put the suggestion I will give to you on INIT().
>
>
>
>
>Follow These Steps:
>
>1 - In INIT()
>
>
DO LOCFILE("System.prg")
>Thisform.AddProperty("RealHWND", 0)
>
>
>
>2 - In ACTIVATE() of your form:
>
>
IF Thisform.RealHWND <> 0
>	DODEFAULT()
>	RETURN
>ENDIF
>
>
>
>DECLARE INTEGER GetWindowRect IN user32 INTEGER hwnd, STRING @lpRect
>DECLARE INTEGER WindowFromPoint IN WIN32API INTEGER x, INTEGER y
>
>#DEFINE EMPTY_RECT   REPLICATE(CHR(0),16)
>
>LOCAL lcRect, lnLeft, lnTop
>lcRect = EMPTY_RECT
>= GetWindowRect(Thisform.hWnd, @lcRect)
>lnLeft = CTOBIN(SUBSTR(lcRect, 1,4),"4RS")
>lnTop  = CTOBIN(SUBSTR(lcRect, 5,4),"4RS")
>
>
>LOCAL lnTitleHeight, lnLeftBorder, lnTopBorder, x1, y1
>lnTitleHeight = SYSMETRIC(9)
>lnLeftBorder = SYSMETRIC(3)
>lnTopBorder = SYSMETRIC(4)
>
>x1 = lnLeftBorder
>y1 = lnTitleHeight + lnTopBorder
>
>Thisform.RealHWND = WindowFromPoint(lnLeft + x1, lnTop + y1)
>
>DODEFAULT()
>
>RETURN
>
>
>
>3 - Create any commandButton, and add the following code:
>
>
WITH _Screen.System.Drawing
>	loGfx = .Graphics.FromHwnd(Thisform.RealHWND)
>	loGfx.FillRectangle(.Brushes.Red, 0,0,100,100)
>ENDWITH
>
>
>Hope this helps you to get started.
>I'm sure I'll find a better way to do that, but for the moment, this was the simplest solution that came to my mind.
>
>
>Hope this helps
>
>Cesar



I've just found another good and maybe better way to retrieve the HWND:

http://www.news2news.com/vfp/?example=27&function=39


The related sample gets the HWNDS from all desktop windows.
Just change the code and send the Main HWND from your form and you'll have the correct value as well
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform