Macros don't return anything. You need the window handle of the control. If you stuck the HorizontalbarGadget line as a macro in a #WM_SIZE event it would create a new window every time it resized, resulting in hundreds of new windows in no time and a memory leak you could drive a truck through.My macro works as expected, as it's replaced with the CreateWindowEx_ line which returns the hWnd.
Add a horizontal line (separator) in form
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
BERESHEIT
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Try it!! Use my macro, create a gadget with it, store the 'returned' hWnd and do whatever you want with the hWnd.netmaestro wrote:Macros don't return anything. You need the window handle of the control. If you stuck the HorizontalbarGadget line as a macro in a #WM_SIZE event it would create a new window every time it resized, resulting in hundreds of new windows in no time and a memory leak you could drive a truck through.My macro works as expected, as it's replaced with the CreateWindowEx_ line which returns the hWnd.
Fred said that macros get processed before the line, which means: this line:
Code: Select all
hWnd=HorizontalBarGadget(0, 5, 5, 100)
Code: Select all
hWnd=CreateWindowEx_(0,...........)
EDIT: REad my post carefully!
Here it's again if you didn't see it correctly:
I said my MACRO gets automatically REPLACED with the CreateWindowEx_ one. The CREATEWINDOWEX_ function RETURNS the HWNDMy macro works as expected, as it's replaced with the CreateWindowEx_ line which returns the hWnd.
I didn't say anything about my macro would return something.
Last edited by josku_x on Sat May 27, 2006 3:50 am, edited 1 time in total.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Yes, I get it - did you read what I said about a memory leak? If you do it that way a new window gets created every time a resize happens - the old one doesn't get freed. If you don't believe me just stick it in your main loop and run with the debugger -> CPU Monitor running. Watch the memory usage for the program rise and rise.
BERESHEIT