|
waldermort wrote: Upon getting the DC it's simply a matter of selecting the 'client region' among others into the DC which prevents drawing on the borders
Are you kidding? I thought you tried that originally!!
That was the first suggestion I responded with.
LOL Glad you got it working and thanks for the update
Mark
|
|
|
|
|
The hurdle was getting ahold of the correct DC to draw to. As you know each window comes with it's own regions, client area DC etc... The DefWindowProc for some controls will check the wParam for a HDC within it's WM_PAINT, but most don't. Besides that, MSDN states that users should not send this message directly but rather send it through an api such as InvalidateRect(). Other than Owner drawn and subclassing, there is no method for us to control how a child window draws.
In answer to your first response, how can you select a region into the DC before DefWindowProc starts it's WM_PAINT or WM_ERASEBKGND. Even after subclassing, I have had to redirect all the drawing to the main windows DC, which basically means, for each control I add, I have to subclass it.
But the end result is well worth the effort. I am now half way to completeing a resizable skinned window library in non MFC.
|
|
|
|
|
Right I got it haha. I was confused once again.
Makes sense now. I wonder if using CS_OWNDC on the background window would work...would windows
use that dc to draw to, and if so, would it select its own clip region into it...
I'll have to try that when I get a chance
Mark
|
|
|
|
|
Hi,
How to send/post a message to the parent view window
so that I can calculate sum of variables which belong to the parent view window
Thanks
Prithaa
|
|
|
|
|
|
Surely there must be a harder way!
Mark
|
|
|
|
|
prithaa wrote: How to send/post a message to the parent view window...
By using SendMessage() or PostMessage() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
Yes I am little bit aware of SendMessage/PostMessage by which I can send a message to the parent window but if I want to find a sum of variables or access a variable of the parent window then Can I do it ? or it is impossible.
I should try some other route.
Any ideas
Prithaa.
|
|
|
|
|
prithaa wrote: ...but if I want to find a sum of variables or access a variable of the parent window then Can I do it ?
Certainly. Prior to calling SendMessage() , allocate memory and pass that address to the parent (as LPARAM ). When the parent responds to the message, it simply assigns the appropriate value.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Certainly. Prior to calling SendMessage(), allocate memory and pass that address to the parent (as LPARAM). When the parent responds to the message, it simply assigns the appropriate value.
Can you please tell me something more about "allocate memory and pass that address to the parent (as LPARAM)".
since I am trying to do it but I not able to do it.
I tried SendMessage(WM_COMMAND,LPARAM,WPARAM);
and the parent window got the message and the control went to ON_Command(WPARAM wParam, LPARAM lParam) function of the parent window which was fine
but memory allocation is what I did not understand.
Prithaa
|
|
|
|
|
int *pValue = new int;
GetParent->SendMessage(MY_MESSAGE, 0, (LPARAM) pValue);
delete pValue; In the handler function for MY_MESSAGE :
LRESULT MyParent::OnMyMessage( WPARAM wParam, LPARAM lParam )
{
*(int *) lParam = 123;
return 0;
}
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
Thanks for the code.It was really useful
But can I make Message map of the form MY_MESSAGE and have a handler function OnMyMessage ?
Since message maps are something that are provided by Windows API and they can be generated through Class Wizard where messages and their corresponding functions are already given. Ex WM_KEYDOWN with function OnKeyDown()
Prithaa
|
|
|
|
|
prithaa wrote: But can I make Message map of the form MY_MESSAGE and have a handler function OnMyMessage ?
Yes, but not with ClassWizard. You need to modify BEGIN_MESSAGE_MAP manually, outside of the //}}AFX_MSG_MAP comment.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
prithaa wrote: How to send/post a message to the parent view window
Views should not know about one another. They should communicate to the "Controller" as in Model-View-Controller
In the MFC Framework you can send messages to Views using CDocument::UpdateAllViews(...). If not using MFC you should have your own MVC design.
led mike
|
|
|
|
|
Hi,
What is MVC design?
Thanks
Prithaa
|
|
|
|
|
|
Hello
I´m trying to do this :
A user starts to write his username in an editcontrol, and as he types
Im searching in a database finding any coincidences with other data I have...
If found one i will show it in other editcontrol else I will disable it.
So at what event from the editcontrol should I put my code?
EN_UPDATE ?
EN_CHANGE ?
or this is not the best way..?
thx in advance...
---------------------------------------------
"Don't panic!. All will become clear in time"
WYS Is Not always WYG
|
|
|
|
|
Hi,
I'm not sure what the appropriate events / method is to use but in JavaScript I use onKeyPress and filtering thought the database.
Can't think of anything else....
Hope this might spark something in your brain .... lol ....
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
|
thx
---------------------------------------------
"Don't panic!. All will become clear in time"
WYS Is Not always WYG
|
|
|
|
|
it will work but might not be practical if the search in the DB takes a long time.
user types "a" waits for a few seconds, user types "c" waits for a few seconds, user types backspace because he wanted to type "v" instead, waits a few seconds, user types "v" ...
|
|
|
|
|
Maximilien wrote: it will work but might not be practical if the search in the DB takes a long time.
I agree. That's why I chose EN_CHANGE - at least the user will see the character typed before
it goes off and searches
|
|
|
|
|
can't you try both and see which one fits you best ?
also, reading the MSDN about those events may help !
|
|
|
|
|
Im on it testing both, just wanted to know a better way.
thx
---------------------------------------------
"Don't panic!. All will become clear in time"
WYS Is Not always WYG
|
|
|
|
|
jarleydg wrote: So at what event from the editcontrol should I put my code?
EN_UPDATE ?
EN_CHANGE ?
The former is sent before the control us updated, whereas the latter is sent after.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|