Add a horizontal line (separator) in form

Just starting out? Need help? Post your questions and find answers here.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

My macro works as expected, as it's replaced with the CreateWindowEx_ line which returns the hWnd.
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.
BERESHEIT
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

ts-soft, very nice piece of work! It's well suited for just this kind of thing as well as having much more potential.
BERESHEIT
josku_x
Addict
Addict
Posts: 997
Joined: Sat Sep 24, 2005 2:08 pm

Post by josku_x »

netmaestro wrote:
My macro works as expected, as it's replaced with the CreateWindowEx_ line which returns the hWnd.
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.
Try it!! Use my macro, create a gadget with it, store the 'returned' hWnd and do whatever you want with the hWnd.

Fred said that macros get processed before the line, which means: this line:

Code: Select all

hWnd=HorizontalBarGadget(0, 5, 5, 100)
equals to this:

Code: Select all

hWnd=CreateWindowEx_(0,...........)
and as far I can tell, createWindowEx returns a hWnd. When you store that hWnd, you can use your #wm_size event without problems at all.


EDIT: REad my post carefully!
Here it's again if you didn't see it correctly:
My macro works as expected, as it's replaced with the CreateWindowEx_ line which returns the hWnd.
I said my MACRO gets automatically REPLACED with the CreateWindowEx_ one. The CREATEWINDOWEX_ function 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.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

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
josku_x
Addict
Addict
Posts: 997
Joined: Sat Sep 24, 2005 2:08 pm

Post by josku_x »

ok I'll check it. but if there's no problems with the memory at all, you shall buy me my coffee :wink:

Hey, let's be friends, I hate war. (although, it would be cool to see you suffer :wink: )
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

josku_x wrote:Hey, let's be friends, I hate war.
First shoot then say "don't shoot back!"?
josku_x wrote:[ color=white ][ size=7 ](although, it would be cool to see you suffer :wink: )[ /size][ /color]
Ease off a bit, please, josku. You're OTT at times.
@}--`--,-- A rose by any other name ..
josku_x
Addict
Addict
Posts: 997
Joined: Sat Sep 24, 2005 2:08 pm

Post by josku_x »

OK. I am going to take things more easily. I know I made mess in this forum. And I know I go very easily off-topic. I am really sorry. Just had a few bad days.
Post Reply