>Hopefully they'll notice this discussion and mark it for improvement.
Hope is not required.
I sent an email with subject "Documentation Improvement Suggestion." Included specific suggestions for improved text.
BTW, there is somewhere on this board an explicit disclaimer that this site is not an official communications channel. So hope is "officially" futile, too.
MCM
Announcement
Collapse
No announcement yet.
How to use GRAPHIC COPY?
Collapse
X
-
Originally posted by Michael Mattias View PostWow, either I have to learn how to read......
... or PB should have used a different variable name in the syntax diagram; "hSource" comes to mind.
"hbmpSource" sure fooled me!
Barry
Leave a comment:
-
Wow, either I have to learn how to read......
GRAPHIC COPY hbmpSource???, id& [, style&]
...
The expression hbmpSource??? specifies the handle of the source bitmapor window.
"hbmpSource" sure fooled me!
Leave a comment:
-
That did it!
I guess that's the combination I didn't try. I have no idea why it works but it does.
Thanks. And thanks for pointing that out about GRAPHIC BITMAP END.
Barry
Leave a comment:
-
Hi Barry,
Code amended from your latest post:
Code:CASE %BTN_SAVE GRAPHIC ATTACH hBmp, 0 GRAPHIC COPY hDlg, %IDC_GRAPHIC GRAPHIC ATTACH hDlg, %IDC_GRAPHIC
Code:GRAPHIC ATTACH hBmp, 0 GRAPHIC BITMAP END
Regards,
Pete.
Leave a comment:
-
I just realized that I left out the GRAPHIC BITMAP END statement so it'll probably produce a memory leak if you run it. Here's the corrected version.
Code:'----------------------------------- ' DDT Template with graphic window and buttons '----------------------------------- #COMPILE EXE #DIM ALL %USEMACROS = 1 #INCLUDE "WIN32API.INC" %IDC_GRAPHIC = 1001 %BTN_PAINT = 2001 %BTN_SAVE = 2002 %BTN_REVERT = 2003 %BTN_EXIT = 1099 %BMPWIDE = 250 %BMPHIGH = 190 GLOBAL hDlg AS LONG GLOBAL hBmp AS LONG '--------------------------- CALLBACK FUNCTION WinProc LOCAL hCtl AS LONG SELECT CASE AS LONG CBMSG CASE %WM_INITDIALOG GRAPHIC BITMAP NEW %BMPWIDE, %BMPHIGH TO hBmp CASE %WM_NCACTIVATE STATIC hWNDSaveFocus AS DWORD IF ISFALSE CBWPARAM THEN ' Save control focus hWndSaveFocus = GetFocus() ELSEIF hWndSaveFocus THEN ' Restore control focus SetFocus(hWndSaveFocus) hWndSaveFocus = 0 END IF CASE %WM_DESTROY GRAPHIC BITMAP END CASE %WM_COMMAND SELECT CASE AS LONG CBCTL CASE %IDC_GRAPHIC CASE %BTN_PAINT GRAPHIC BOX (RND(20,30),RND(20,30)) - (RND(80,180),RND(40,170)) CASE %BTN_SAVE CONTROL HANDLE hDlg, %IDC_GRAPHIC TO hCtl GRAPHIC ATTACH hDlg, hBmp GRAPHIC COPY hCtl, %IDC_GRAPHIC GRAPHIC ATTACH hDlg, %IDC_GRAPHIC CASE %BTN_REVERT GRAPHIC COPY hBmp, 0 CASE %BTN_EXIT IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN DIALOG END CBHNDL END IF END SELECT END SELECT END FUNCTION '--------------------------- FUNCTION PBMAIN () AS LONG DIALOG NEW PIXELS, 0, "Template", 10,10, 340,200, _ %WS_SYSMENU OR %WS_DLGFRAME OR %WS_BORDER, TO hDlg DIALOG SET COLOR hDlg, -1, %GREEN CONTROL ADD BUTTON, hDlg, %BTN_PAINT, "Paint", 275,70, 50,20 CONTROL ADD BUTTON, hDlg, %BTN_SAVE, "Save", 275,100, 50,20 CONTROL ADD BUTTON, hDlg, %BTN_REVERT, "Revert", 275,130, 50,20 CONTROL ADD BUTTON, hDlg, %BTN_EXIT, "Exit", 275,170, 50,20 CONTROL ADD GRAPHIC, hDlg, %IDC_GRAPHIC, "", 5,5, %BMPWIDE,%BMPHIGH, _ %WS_CHILD OR %WS_VISIBLE, %WS_EX_CLIENTEDGE GRAPHIC ATTACH hDlg, %IDC_GRAPHIC GRAPHIC COLOR -1, %WHITE 'GRAPHIC PAINT BORDER (20,20), ltgray, green,0 DIALOG SHOW MODAL hDlg, CALL WinProc END FUNCTION
Leave a comment:
-
Here's an example program to illustrate what's happening.
I'm assuming that I'm using GRAPIC COPY wrong but I've tried everything I can think of.
Thanks,
Barry
Code:'----------------------------------- ' DDT Template with graphic window and buttons '----------------------------------- #COMPILE EXE #DIM ALL %USEMACROS = 1 #INCLUDE "WIN32API.INC" %IDC_GRAPHIC = 1001 %BTN_PAINT = 2001 %BTN_SAVE = 2002 %BTN_REVERT = 2003 %BTN_EXIT = 1099 %BMPWIDE = 250 %BMPHIGH = 190 GLOBAL hDlg AS LONG GLOBAL hBmp AS LONG '--------------------------- CALLBACK FUNCTION WinProc LOCAL hCtl AS LONG SELECT CASE AS LONG CBMSG CASE %WM_INITDIALOG GRAPHIC BITMAP NEW %BMPWIDE, %BMPHIGH TO hBmp CASE %WM_NCACTIVATE STATIC hWNDSaveFocus AS DWORD IF ISFALSE CBWPARAM THEN ' Save control focus hWndSaveFocus = GetFocus() ELSEIF hWndSaveFocus THEN ' Restore control focus SetFocus(hWndSaveFocus) hWndSaveFocus = 0 END IF CASE %WM_COMMAND SELECT CASE AS LONG CBCTL CASE %IDC_GRAPHIC CASE %BTN_PAINT GRAPHIC BOX (RND(20,30),RND(20,30)) - (RND(80,180),RND(40,170)) CASE %BTN_SAVE CONTROL HANDLE hDlg, %IDC_GRAPHIC TO hCtl GRAPHIC ATTACH hDlg, hBmp GRAPHIC COPY hCtl, %IDC_GRAPHIC GRAPHIC ATTACH hDlg, %IDC_GRAPHIC CASE %BTN_REVERT GRAPHIC COPY hBmp, 0 CASE %BTN_EXIT IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN DIALOG END CBHNDL END IF END SELECT END SELECT END FUNCTION '--------------------------- FUNCTION PBMAIN () AS LONG DIALOG NEW PIXELS, 0, "Template", 10,10, 340,200, _ %WS_SYSMENU OR %WS_DLGFRAME OR %WS_BORDER, TO hDlg DIALOG SET COLOR hDlg, -1, %GREEN CONTROL ADD BUTTON, hDlg, %BTN_PAINT, "Paint", 275,70, 50,20 CONTROL ADD BUTTON, hDlg, %BTN_SAVE, "Save", 275,100, 50,20 CONTROL ADD BUTTON, hDlg, %BTN_REVERT, "Revert", 275,130, 50,20 CONTROL ADD BUTTON, hDlg, %BTN_EXIT, "Exit", 275,170, 50,20 CONTROL ADD GRAPHIC, hDlg, %IDC_GRAPHIC, "", 5,5, %BMPWIDE,%BMPHIGH, _ %WS_CHILD OR %WS_VISIBLE, %WS_EX_CLIENTEDGE GRAPHIC ATTACH hDlg, %IDC_GRAPHIC GRAPHIC COLOR -1, %WHITE 'GRAPHIC PAINT BORDER (20,20), ltgray, green,0 DIALOG SHOW MODAL hDlg, CALL WinProc END FUNCTION
Leave a comment:
-
Originally posted by Michael Mattias View PostCode:CASE %BTN_HOLD .... GRAPHIC COPY [B]hCtl, %IDC_GRAPHIC1[/B] CASE %BTN_REVERT GRAPHIC COPY [B]hBmpRevert, 0[/B]
In case two param one is a handle to a graphic and param two null.
My doc says param one should be a handle to a BMP and param 2 the ID used in the CONTROL ADD GRAPHIC statement.
MCM
That's not a general complaint about PB's docs. They're very good as a rule but I can't pin down just what this page means.
I can't really post my program since it won't compile without the accompanying resources (a lot of bitmaps) so I'm making up a small test program to illustrate my problem. I'll post it today or tomorrow.
Thanks,
Barry
Leave a comment:
-
Code:CASE %BTN_HOLD .... GRAPHIC COPY [B]hCtl, %IDC_GRAPHIC1[/B] CASE %BTN_REVERT GRAPHIC COPY [B]hBmpRevert, 0[/B]
In case two param one is a handle to a graphic and param two null.
My doc says param one should be a handle to a BMP and param 2 the ID used in the CONTROL ADD GRAPHIC statement.
MCM
Leave a comment:
-
If you could post a small compilable example that shows the problem you'll likely get some suggestions. Maybe even helpful ones
Leave a comment:
-
How to use GRAPHIC COPY?
I'm having a problem getting graphic copy to work. I'm copying from a DDT graphic control to a bitmap created with GRAPHIC BITMAP NEW. This is in a little drawing program to create a revert point. When I copy it back I get a black graphic control.
I created both the control and the bitmap 500x500. I'm using pixels, not graphic units. Here's the code for the "hold" and "revert" buttons:
Code:CASE %BTN_HOLD CONTROL HANDLE hDlg, %IDC_GRAPHIC1 TO hCtl GRAPHIC ATTACH hDlg, hBmpRevert GRAPHIC COPY hCtl, %IDC_GRAPHIC1 GRAPHIC ATTACH hDlg, %IDC_GRAPHIC1 CASE %BTN_REVERT GRAPHIC COPY hBmpRevert, 0
Does anyone have any idea what's going on? Any suggestions will be most appreciated and just might save some of what little hair I have left.
Thanks,
BarryTags: None
Leave a comment: