Hi
(http://img.ir/gyn.png)
I wanna make that static controls in my application and be able to change its colors and size, Can somebody help me in this?
You must subclass it or use your own user defined class and process the messages needed to show those counters. I'm going to work something out and post later. Ok? Thanks for letting me help. Got to get my hands back on ASM.
Thank you , any help would be most welcome
For a 7-segment style display, without a scalable 7-segment font the size change will be difficult.
Quote from: MichaelW on January 20, 2013, 07:14:02 AM
For a 7-segment style display, without a scalable 7-segment font the size change will be difficult.
Sounds like a nice little project. LUTs, CreatePolygon, FillRgn, ... ;-)
i would probably use StretchBlt and draw my own :P
I doubt that StretchBlt would produce good results. I think drawing the digits as a collection of polygons could produce good results, but doing so would be difficult.
well - it isn't quite clear what he wants
he says he wants "...able to change its colors and size"
but, he doesn't really say if he wants that on the fly or case-by-case
even so - StretchBlt will do fairly well if you SetStretchBltMode to HALFTONE and SetBrushOrgEx
For a Windows program I would not bother with any sort of N-segment display. They were a good development in their time, and there are still good reasons to use them for certain applications, but why accept their limitations when you don't have to.
If you want to draw to the static control you have to use GetWindowLong and change the default procedure address. I cant find any easy way to that directly without changing the control procedure.
That was fiddly ... in the attachment an example (GDI) that may be used as a base.
qWord
EDIT upload: some changes to reduce CPU usage . Also WM_DESTROY was not process by the control.
EDIT2: Further improvements
Quote from: dedndave on January 20, 2013, 10:43:10 AM
StretchBlt will do fairly well if you SetStretchBltMode to HALFTONE and SetBrushOrgEx
The attachment contains a quick and dirty test app. I can't see any effect from SetStretchBltMode and SetBrushOrgEx, perhaps because I'm doing something wrong, but even so StretchBlt does much better than I thought it would.
Correction, I can see an effect, but I have to capture the window and zoom it up. The effect does improve the image quality, but it is present only when the size is reduced, and for the best quality you need to be working with a 24-bit bitmap. So it looks like the way to do this is to create the digit bitmap at the largest size, and reduce the size as necessary. The second attachment contains a sample of the result.
Quote from: qWord on January 20, 2013, 05:39:45 PM
That was fiddly ... in the attachment an example (GDI) that may be used as a base.
qWord
Did it drawn on each static control like he want? I see you use a timer for trigering the drawing.
Hi qWord,
well written example. :t
Gunther
one thing you may have noticed, Michael
HALFTONE mode is a lot slower than COLORONCOLOR - lol
nice examples, guys :t
Thank you guys for your helps specially Qword and Michael.
I just imported Qword's nice example to my application , and now im working on changing its colors while my program is running.
Quote from: dedndave on January 21, 2013, 01:06:12 AM
one thing you may have noticed, Michael
HALFTONE mode is a lot slower than COLORONCOLOR – lol
I could not see the difference, but in my crude test looping the code 1000 times directly in the WM_PAINT handler and measuring the loop time with GetTickCount, I get:
~900ms for COLORONCOLOR
~3200ms for HALFTONE
qWord example a bit compilicated but he is right by using SetWindowLong. You have to create your own procedure for each control and intercept the message.
Quote from: qWord on January 20, 2013, 05:39:45 PM
That was fiddly ... in the attachment an example (GDI) that may be used as a base.
qWord
EDIT upload: some changes to reduce CPU usage . Also WM_DESTROY was not process by the control.
EDIT2: Further improvements
Hey qWord,
I seem to get errors with the Ampersand "&"
Why ? :(
DigitalClock.asm(63) : error A2008: syntax error : &
fn(5): Macro Called From
DigitalClock.asm(87) : error A2008: syntax error : &
fn(5): Macro Called From
same in the Cntrl.asm
Thank you !
Quote from: hfheatherfox07 on January 23, 2013, 10:32:01 AM
I seem to get errors with the Ampersand "&"
Replace "&" with "addr"
Quote from: digelo on January 23, 2013, 10:57:01 AM
Quote from: hfheatherfox07 on January 23, 2013, 10:32:01 AM
I seem to get errors with the Ampersand "&"
Replace "&" with "addr"
Thank you that did it !
@echo off
C:\masm32\bin\ml /c /coff DigitalClock.asm
C:\masm32\bin\ml /c /coff Cntrl.asm
C:\masm32\bin\\link.exe /subsystem:windows DigitalClock.obj Cntrl.obj
pause
lol
never mind too many windows open at one time :icon_redface:
Sorry i took so long. Some nice stuff already. Gotta catchup. Here's my shit example. I think that this is more or less what was intended. Thanks
Hey.... btw. Theres some problems with that example. I think it has to do with the memory allocated by the controls. It doesn't seem to free. is it still WM_DESTROY WM_CLOSE for child windows?
It's fixed.
Works fine :t
You can close a child window by sending WM_CLOSE, 0, 0 - the destroy is automatic then.
That's not what i meant. For example, ... in this case you have a child window - the counter. The Counter has more children and allocates memory to allow independece of use, so you can create more than one control. When you click the close button on the top-right corner you get the WM_DESTROY. What does the child window get? i need to get the that memory freed. Anyway i used Heap Functions and then it seems to work.
All windows receive WM_DESTROY/WM_NCDESTROY - that is the place which can be used to free resources.
Also, the common way to remove a child control is to call DestroyWindow() and not sending WM_CLOSE - this is message is send when the X-Button or Alt-F4 (...) of a TLW is pressed.
Messages = child
Messages MAIN = parent
Messages MAIN
chg:msgCount 132
uMsg 16
# debChgMsg # WM_SYSCOMMAND <<<< the click in the upper right corner
Messages MAIN
chg:msgCount 133
uMsg 70
# debChgMsg # WM_CLOSE
...
Messages
chg:msgCount 140
uMsg 641
# debChgMsg # WM_KILLFOCUS
...
Messages
chg:msgCount 144
uMsg 130
# debChgMsg # WM_DESTROY
Messages MAIN
chg:msgCount 145
uMsg 130
# debChgMsg # WM_DESTROY
well - the destroy operation is not quite automatic for WM_CLOSE
when a window receives a WM_CLOSE message, the default processing is to call DestroyWindow
if the WndProc for that window processes the WM_CLOSE message without calling DefWindowProc,
and without calling DestroyWindow, then it may not be destroyed
this gives the coder an opportunity to offer an "ok to close" message box or something similar
WM_CLOSE is sent to "ask" a window to shut down
WM_DESTROY is sent to tell a window it is being destroyed
when WM_DESTROY is sent, the window has already been removed from the screen
but - WndProc is obviously still handling this one message
thanks... been away for a while. Thanks for the replies. Yeah beacause i was getting errors. But i used HeapAllocs and there was no need for freeing.
Quote from: xandaz on February 04, 2013, 10:51:35 AMBut i used HeapAllocs and there was no need for freeing.
Even Microsoft believes that ExitProcess does that job. My practical experience is that if a proggie that made a huge HeapAlloc crashes, the system can become so slow that you are forced to reboot. Remember that HeapAlloc passes huge requests on to VirtualAlloc.
well jj... i haven't experienced anything of the sort but it's useful information. thanks
well , my brothers and sisters. After having made that counter i tried to make the as if it could be reused several times in different controls but it doesn't seem to work. only the first two are visible and the second misses the titlles and the other two, well.... the windows were created but i can't see them.
invoke CreateWindowEx,WS_EX_STATICEDGE,addr CounterClass,addr ci,WS_VISIBLE+WS_CHILD+WS_CLIPSIBLINGS,\
0,0,rect.right,rect.bottom,hWnd,0,hInstance,0
mov hCounter1,eax
invoke CreateWindowEx,WS_EX_STATICEDGE,addr CounterClass,addr ci2,WS_VISIBLE+WS_CHILD+WS_CLIPSIBLINGS,\
rect.right,0,rect.right,rect.bottom,hWnd,0,hInstance,0
mov hCounter2,eax
invoke CreateWindowEx,WS_EX_CLIENTEDGE,addr CounterClass,addr ci3,WS_VISIBLE+WS_CHILD+WS_CLIPSIBLINGS,\
rect.right,rect.bottom,rect.right,rect.bottom,hWnd,0,hInstance,0
mov hCounter3,eax
invoke CreateWindowEx,WS_EX_CLIENTEDGE,addr CounterClass,addr ci4,WS_VISIBLE+WS_CHILD+WS_CLIPSIBLINGS,\
0,rect.bottom,rect.right,rect.bottom,hWnd,0,hInstance,0
mov hCounter4,eax
1) i think you intend the first 2 to use StaticClass
2) notice the positions x,y,width,height - some of them are outside the main client
the first one fills the client area :P
3) i think it's a good idea to assign unique control identifiers for child windows (hMenu parm)
for testing, just put constants in there for position and size - then put some vars when you have it working
sure thing dave. it was just a rough example...