The MASM Forum

General => The Workshop => Topic started by: raymond on February 06, 2013, 12:19:00 PM

Title: Ghost edit controls
Post by: raymond on February 06, 2013, 12:19:00 PM
I'm in the process of writing a program where I need to place edit controls in various cells of a grid in the main window. Some of the cells are gray, others are white. I use the CreateWindow function for creating and placing the controls.

Later, I need to redraw the grid and need to place the controls generally in different cells of the grid. I use the DestroyWindow function to get rid of all the existing controls before starting to redraw the grid and add the required controls.

However, the white footprint of any previous edit controls (which have been destroyed) does not get covered by any gray filling using the FillRect function.

Has anyone ever experienced such a situation or know any remedy?
Title: Re: Ghost edit controls
Post by: qWord on February 06, 2013, 12:43:17 PM
Do you invalidate the control's regions after deleting them? Also, did you draw that rectangles in context to WM_PAINT?
Title: Re: Ghost edit controls
Post by: dedndave on February 06, 2013, 01:36:04 PM
hi Ray
maybe you could make a small example ?
Title: Re: Ghost edit controls
Post by: raymond on February 06, 2013, 01:39:27 PM
QuoteDo you invalidate the control's regions after deleting them?

No. I just tried to paint over them. They are supposed to have been DESTROYED.

QuoteAlso, did you draw that rectangles in context to WM_PAINT?

No. I've got several dozens of those control to create and position.

However, I've just found a solution. :eusa_clap: :eusa_clap: :eusa_clap:
I was looking for some function which would modify their size to 0x0 and didn't find one. But using the MoveWindow function to move them to a dead area of the main window before destroying them works like a charm.

It's amazing how often we can't see solutions until we start asking for help. I must have spent numerous hours last night trying to find some way out!!! A little more patience on my part may have avoided this silly post. :eusa_boohoo:
Title: Re: Ghost edit controls
Post by: dedndave on February 06, 2013, 01:43:26 PM
yes - sizing them to 0,0 does the trick - lol
if you do that, the position doesn't usually matter
i sometimes set the pos to 0,0, as well as the size

you may be able to use ShowWindow with SW_HIDE in a similar manner

maybe you don't have to destroy them - make them "reusable"
Title: Re: Ghost edit controls
Post by: raymond on February 06, 2013, 01:49:06 PM
Quotemaybe you don't have to destroy them - make them "reusable"

That may be easy to do when you have only a few of them. It could be a nightmare trying to manage some 5 dozens of those windows. :dazzled:
Title: Re: Ghost edit controls
Post by: hutch-- on February 06, 2013, 04:21:09 PM
Ray,

In the distant past I have seen the logic where the grid is done with an array of static controls and the editing is done with a single edit control superimposed over the static control at a given location. On completion entering the data the content is copied to the memory of the static control at that location.
Title: Re: Ghost edit controls
Post by: raymond on February 06, 2013, 04:50:36 PM
I guess you all deserve to have a look at what I was working on. The attached zip is a folder containing the .exe, an .ini file and two "data" files. If you want to know what its purpose might be, visit http://krazydad.com/.

BTW, I tried e-mailing this zip file to the author of that site and gmail simply refused to deliver it. Part of the returning message was: ::) ::)

hostgmail-smtp-in.l.google.com[74.125.25.27] said: 552-5.7.0 Our systemdetected an illegal attachment on your message. Please 552-5.7.0 visit http://support.google.com/mail/bin/answer.py?answer=6590 to 552 5.7.0review our attachment guidelines.

:icon13: :eusa_boohoo: :eusa_boohoo: :icon13: :dazzled: :dazzled:
Title: Re: Ghost edit controls
Post by: jj2007 on February 06, 2013, 05:20:02 PM
Quote from: raymond on February 06, 2013, 04:50:36 PMBTW, I tried e-mailing this zip file to the author of that site and gmail simply refused to deliver it

Ray,
After downloading the message Firefox said "Scanning for viruses...". That was five minutes ago, it's still scanning, but MSE had no problems to let me open it, and it looks really nice :t
Title: Re: Ghost edit controls
Post by: MichaelW on February 06, 2013, 05:31:59 PM
I downloaded it with IE8 no problem, and MSE found no problems, but if I drag the client area of the window off screen and then back, the contents of the edit controls on the right side are erased, and the GO and CHECK buttons don't redraw correctly.
Title: Re: Ghost edit controls
Post by: qWord on February 06, 2013, 10:50:09 PM
raymond,
to avoid that the controls are paint over (see MichaelW's post), use the WS_CLIPCHILDREN style for the main window.  If you destroy a window, you should invalidate the region that was covered by it. The parent window then receives a WM_PAINT message to redraw that region:

1. GetWindowRect,hEdit,addr rect -> ScreenToClient,hParent,addr rect.left / rect.rigth
2. DestroyWindow,hEdit
3. InvalidateRect,hParent,addr rect,...

Alternatively, you can invalid the whole client are after destroying the controls by using InvalidateRect(hParent,0,...).
Title: Re: Ghost edit controls
Post by: Tedd on February 07, 2013, 12:52:46 AM
I'd go the other way and suggest drawing the grid and values yourself, and then dynamically create a single edit control on top of the selected cell for editing. The result could be much nicer and more flexible, though obviously a little more work too.
Title: Re: Ghost edit controls
Post by: hfheatherfox07 on February 09, 2013, 06:19:49 PM
Quote from: raymond on February 06, 2013, 04:50:36 PM

BTW, I tried e-mailing this zip file to the author of that site and gmail simply refused to deliver it. Part of the returning message was: ::) ::)

hostgmail-smtp-in.l.google.com[74.125.25.27] said: 552-5.7.0 Our systemdetected an illegal attachment on your message. Please 552-5.7.0 visit http://support.google.com/mail/bin/answer.py?answer=6590 to 552 5.7.0review our attachment guidelines.

:icon13: :eusa_boohoo: :eusa_boohoo: :icon13: :dazzled: :dazzled:

Hello,
G mail does not allow sending any exe' dll's period !
Nothing to do with your particular app
I used to use " copy b " in the command prompt to copy the archive into a pic and send it that way,
The person reciving it can extract it with winrar or any archive extractor !
Not sure if they wised up to that trick ... :(
Title: Re: Ghost edit controls
Post by: raymond on February 10, 2013, 11:48:59 AM
Yes. I did see afterwards their list of no-no's to be attached to e-mails, whether zipped or not. One option is to rename it with any acceptable extension (such as .txt, or .abc, etc.) before zipping it and let the receiver know which file to rename with the proper extension.
Title: Re: Ghost edit controls
Post by: dedndave on February 10, 2013, 11:56:21 AM
i use hotmail for that   :P

if you really wanna obfuscate things
RAR or 7Z it, then stick that inside a zip
you can even password protect these compressed files if you like
Title: Re: Ghost edit controls
Post by: raymond on February 10, 2013, 12:40:29 PM
Quotei use hotmail for that

I also used hotmail and had no problem with them accepting to send it off. The problem was that the recipient's e-mail address was with Gmail. That's where they refused to deliver it and returned it back!