Also, when using BeginPaint() and EndPaint(), is it necessary to DeleteObject for any pens created and ReleaseDC?
Also, you cannot delete any object that is still selected into a Device Context - the following psuedocode example demonstrates how to correctly handle the dynamic creation and destruction of GDI objects:
Code:
'psuedocode CASE %WM_PAINT hDC = BeginPaint(...) hBrush = CreateBrushIndirect(...) hBrushOld = SelectObject(hDC, hBrush) ...drawing code DeleteOnject SelectObject(hDC, hBrushOld) EndPaint <params>
When creating new graphs/displays for the other tab pages, would you recommend setting up seperate subclass functions to handle this via:
I'm not at my DEV PC to run your code, but a quick look reveals that your code does not have a message pump for the child dialogs, so the events for these dialogs are never dispatched.
The correct way to handle this would work like this:
1. Create the parent dialog, and the tab control as a child control to that dialog. The dialog should have the extended %WS_EX_CONTROLPARENT style.
2. Create the child (modeless) dialogs as children of the main dialog, NOT the tab control. These dialogs should have the %DS_CONTROL style.
3. Use a DIALOG SHOW MODELESS statement for each of the child dialogs, and then hide each one with DIALOG SET STATE (or is it DIALOG SHOW STATE, I forget)
4. Use DIALOG SHOW MODAL to launch the main dialog.
5. In the dialog handler for the main dialog, process %WM_INITDIALOG and use PostMessage CBHNDL,%WM_USER + 999,0,0 to post a user-defined message to itself.
6. Process %WM_USER + 999& and execute a DIALOG DOEVENTS message loop which should run until the child modeless dialogs are all destroyed. This means that this event handler should run all the time, but the callback will still be able to process other messages normally.
The message pump for the modeless dialogs should look something like this:
Code:
SELECT CASE CBMSG CASE %WM_INTIDIALOG ... general init code goes here. PostMessage CHNDL, %WM_USER+999, 0, 0 EXIT FUNCTION CASE %WM_USER + 999 DO DIALOG DOEVENTS to nModelessCount& ' (check the syntax here... this is off the top of my head!) LOOP UNTIL nModelessCount& = 0 EXIT FUNCTION
I hope this helps. Tab controls are a challenge, but forgetting the message pump for modeless dialogs is a common mistake.
There is another approach to this whole tab control application - simply use modeless dialogs for everything, and place the message pump in the main (PBMAIN) code.
if this is a better choice for you, then the process would work like this:
1. Create the parent dialog, and the tab control as a child control to that dialog. The dialog should have the extended %WS_EX_CONTROLPARENT style.
2. Create the child (modeless) dialogs as children of the main dialog, NOT the tab control. These dialogs should have the %DS_CONTROL style.
3. Use a DIALOG SHOW MODELESS statement for each of the child dialogs, and then hide each one with DIALOG SET STATE (or is it DIALOG SHOW STATE, I forget)
4. Use DIALOG SHOW MODELESS to launch the main dialog.
5. start the message pump right here in PBMAIN.
Code:
'psuedocode FUNCTION PBMAIN() DIALOG NEW 0,..., to hDlg CONTROL ADD "thetabcontrolclassname",..., to hTab DIALOG NEW hDlg,..., to hTabPage1 DIALOG NEW hDlg,..., to hTabPage2 DIALOG NEW hDlg,..., to hTabPage3 DIALOG SHOW MODELESS hTabPage1 CALL ChildTabCallback1 DIALOG SHOW MODELESS hTabPage2 CALL ChildTabCallback2 DIALOG SHOW MODELESS hTabPage3 CALL ChildTabCallback3 DIALOG SHOW MODELESS hDlg CALL ParentCallback DO DIALOG DOEVENTS To nModelessCOunt& LOOP UNTIL nModelessCount& = 0 END FUNCTION

------------------
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>
Leave a comment: