PDA

View Full Version : treeview + viewport + tbgl ?



largo_winch
03-08-2011, 13:42
hello. I wanted to know how to insert a tbgl window into viewport example? (sample folder: ui/viewport). my tbgl attempt starts about line 233. see tbasic example plus icon folder in zip folder.
bye, largo

Petr Schreiber
03-08-2011, 15:31
Hello hello,

you almost got it working! You need to tune up the Dialog creation styles.

Currently you have there:


Dialog New Pixels, hViewPort, "Dialog with TBGL",-1,-1, %MAIN_WIDTH, %MAIN_HEIGHT, _
%WS_POPUP Or %WS_VISIBLE Or _
%WS_CLIPCHILDREN Or %WS_CAPTION Or _
%WS_SYSMENU Or %WS_MINIMIZEBOX Or %WS_MAXIMIZEBOX Or %WS_THICKFRAME, 0 To hDlg


... but as the dialog will be embedded, there is no need for sysmenu, caption, maximize buttons and so on. And on the other side you need to include %WS_CHILD style (because you want to nest dialog in another dialog).
As a result, replace the code above with:


Dialog New Pixels, hViewPort, "",0,0, %MAIN_WIDTH, %MAIN_HEIGHT, _
%WS_VISIBLE Or %WS_CHILD Or %WS_CLIPCHILDREN, 0 To hDlg


And voila! You have your TBGL box looking at you :)


Petr

P.S. Tip: The icon you used for TBGL in treeview can be partially transparent, if you paint transparent parts with 255, 0, 255 (also known as "magenta from hell")

largo_winch
04-08-2011, 08:28
1) thanks for your help.

2) hello. hi petr. I have made some additions to the "image" folder of treeview + viewport example in my new example. I added little toolbar, menu too if somebody has interests to do such way.

3) image folder with "imagectx" didn't load the image (any image), so there must be something wrong in original code. / I tried to add a button for "load" (and "ok") but this buttons don't work in that selected "image folder" window. I don't know why ;(
I add a picture (flower) that can be loaded by "icon" folder. btw: you can touch this picture with mouse and move it to another place.

all you can test in zip folder. pure *tbasic example I add too.

the viewport example is very interesting stuff. I like that one!

4) my new "tbgl" folder run's ok with icon button to click :)

thanks, largo

Petr Schreiber
04-08-2011, 10:15
Hi Largo,

thanks for updated example, it worked fine even on Windows 7.

The problem with buttons is related to your %WM_MOUSEACTIVATE handling - they cannot be clicked, because they are moved instead.
To fix this, just modify the case to:


Case %WM_MOUSEACTIVATE
Local PA1 As POINTAPI
Local PA2 As POINTAPI
Local hWndCtrl As DWord
Local hImageCtrl As DWord
Win_GetCursorPos( PA1 )
Win_ClientToScreen( CBHNDL, PA2 )

' -- What did we get
hWndCtrl = Win_ChildWindowFromPoint( CBHNDL, PA1.X - PA2.X, PA1.Y - PA2.Y )
hImageCtrl = Control_GetHandle(CBHNDL, %IDC_IMAGECTX_STRETCH)

' -- Is it our picture control? Yes? Then let's move it!
If hWndCtrl = hImageCtrl Then
If hWndCtrl <> CBHNDL Then

Win_SetForeground hWndCtrl
IMAGECTX_Redraw CBHNDL, %IDC_IMAGECTX_STRETCH
Win_PostMessage hWndCtrl, %WM_NCLBUTTONDOWN, %HTCAPTION, 0

Function = %MA_ACTIVATEANDEAT
End If
End If
'---

This way it will not move everything, but just the image control.
This is assured by testing whether the handle of control found equals to handle of image control.


Petr