News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Creating picture box

Started by Farabi, July 23, 2008, 05:34:22 AM

Previous topic - Next topic

Farabi

How to create a picture box using CreateWindowEx? And is it flicker free if I redraw into its DC?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

hutch--

Farabi,

If you don't have to modify the image, use a static control with the SS_BITMAP style. Easiest way to do it.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Farabi

Quote from: hutch-- on July 23, 2008, 09:25:32 AM
Farabi,

If you don't have to modify the image, use a static control with the SS_BITMAP style. Easiest way to do it.
No, I want to modify the image.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

MichaelW

By "picture box" I assume you mean something like a VB PictureBox control. What sort of image(s) does the control need to handle? A PictureBox control can expand to fit the image or clip the image to fit the control. I think with GDI+ you could do either, or resize the image to fit the control, or transform the image, or draw in the control, and handle a wider range of image types than a static control. There are some examples, in PowerBASIC syntax, here.
eschew obfuscation

Farabi

Quote from: MichaelW on July 23, 2008, 03:08:18 PM
By "picture box" I assume you mean something like a VB PictureBox control. What sort of image(s) does the control need to handle? A PictureBox control can expand to fit the image or clip the image to fit the control. I think with GDI+ you could do either, or resize the image to fit the control, or transform the image, or draw in the control, and handle a wider range of image types than a static control. There are some examples, in PowerBASIC syntax, here.
If I draw directly to the window DC, the button also the richedit picture is overwriten . Thats why I want to draw it to a picture box, so the button and the richedit picture can still exist.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

donkey

I used a custom control in TBPaint for the picture box (though in reality it is little more than a static control), early on it only handled the WM_PAINT message, sending the rest to the default static proc but over development it grew to quite a size handling all sorts of messages as well as routing all drawing functions. All you have to do is create a bitmap, modify it as you like then when the control receives a WM_PAINT message blt the bitmap into the control, just be sure to invalidate the control after drawing to the MemDC. Any overwriting of other children can be handled through clipping so that is not an issue. I found that using a backbuffer when drawing to the control kept it virtually flicker free and allowed me more flexibility when drawing since I was essentially drawing directly to memory then blting the result. Actually the memory DC that is used for drawing in TBPaint is permanent, always containing the current bitmap, the control is only used to display the results, all drawing is done directly to the memory DC not the control's DC.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Farabi

Donkey:
Here is my project, its very complicated and mess up. I dont understand how to implement your answers. Please take a look at my code.

PS:
If one or more function on my project is usefull for you, dont hestitate to take it. Its all yours.

[attachment deleted by admin]
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

Take a look at "ButtonCheck" procedure, the bottom line is the blit function.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

donkey

Hi Farabi,

It's close to 11PM here so I won't have time to look it over tonight but I will try to take a look tomorrow aftter work. Thanks for the offer but I don't do very much with graphics right now, I am more interested in ODBC and SQL with assembly and all of my current projects revolve around that however I will archive it and if I ever need it I will give you a heads up.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

hutch--

Farabi,

If you want to modify the image, use a window and the API BitBlt, fast slick and reliable.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Relvinian

This is some very old code (9-10 yrs ago) from a project of mine (the function calls to the system routines might not be the same as MASM32 but they are very close so little work is needed to change it).

This will draw any HBITMAP handle on the screen and should be flicker-free for your normal use.  Hope this old code will help you with what you are doing.

Relvinian


[attachment deleted by admin]

Farabi

Quote from: Relvinian on July 24, 2008, 07:29:40 PM
This is some very old code (9-10 yrs ago) from a project of mine (the function calls to the system routines might not be the same as MASM32 but they are very close so little work is needed to change it).

This will draw any HBITMAP handle on the screen and should be flicker-free for your normal use.  Hope this old code will help you with what you are doing.

Relvinian


Hi, thanks for your code. Have you look into my code? My problem is, when I blit to the window DC the edit box and push button draw dissapear.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

Quote from: hutch-- on July 24, 2008, 05:18:10 AM
Farabi,

If you want to modify the image, use a window and the API BitBlt, fast slick and reliable.
I already use it, But It overwrote the textbox and the push button. On delphi I can mix the GDI and the control button like this


But I dont know how to do it on MASM.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

jj2007

You might have a look at the regions functions, e.g. CreatePolygonRgn, then:

The PaintRgn function paints the specified region by using the brush currently selected into the device context.

Now, a brush can be simply a bitmap...

Tedd

You need to paint the bitmap as 'background', then any buttons or other controls will be drawn on top and show nicely.

When processing WM_PAINT, just do the usual BeginPaint/EndPaint, and bitblt the image data within that.
To avoid flicker, you'll want to create a memory-dc and do all drawing onto that. Then it will actually be displayed on screen during the WM_PAINT. Also, you'll need to InvalidateRect to force repaints when the image changes.
No snowflake in an avalanche feels responsible.