|
I don't quite understand your point for not wanting to do it this way. Here is more information for WM_ERASEBKGND.
WM_ERASEBKGND is called when you call ::BeginPaint or use the CPaintDC inside of your WM_PAINT handler. If you try to do this in the WM_PAINT handler or somewhere else, you will get a flicker from the default handler for WM_ERASEBKGND erasing the background to white.
The wParam in WM_ERASEBKGND is the HDC that you should use to erase the background. This HDC is pre-initialized with the update region for the window, so it will clip anything automatically for you. Use this code:
COLORREF clr = RGB(255,0,255);
HBRUSH br = ::CreateSolidBrush(clr);
RECT rClient;
::GetClientRect(hWnd, &rClient);
::FillRect((HDC)wParam, &rClient, br);
::DeleteObject(br);
|
|
|
|
|
The solution is :
CView::OnEraseBkgnd(CDC* pDC)
{
CBrush backBrush(RGB(0, 0, 0));
// Save old brush
CBrush* pOldBrush = pDC->SelectObject(&backBrush);
CRect rect;
pDC->GetClipBox(&rect); // Erase the area needed
pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(),
PATCOPY);
pDC->SelectObject(pOldBrush);
return TRUE;
//return CView::OnEraseBkgnd(pDC);
}
don't use return CView::OnEraseBkgnd(pDC);
|
|
|
|
|
Hi,
I have a vanilla SDI app with a scroll view in it. I have also created a CWnd derived window intended to be used as a child window in a dialog etc to pick colors from. It is populated with about 400 colors obtained from a 3rd party source.
All drawing seems to be OK, apart from:
I choose a color in my derived child window, then click in the SDI view to 'draw with it' and the colors don't match up. I'm not sure if the view or the child window is drawing the colors wrong (hopefully not both as the colors are different!). I did put the RGB value of one color into Paint SHop Pro and it corresponded to the view, so I think the view is right.
Is there anything you have to do to get a window (my derived child window) to have the same color depth as the view? Or is something else amiss?
Thanks in advance,
Simon
|
|
|
|
|
If you've managed to make different parts of your screen the same colour depth then I salute you. You may have a DIBSection that you are drawing on, and it may be any colour depth, so check that first - if it's 8 bit then there's your problem right there.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Christian,
Thanks for the response.
To be honest, I think there is a problem with the CDC that I am given. I simply pass it to the render function that creates a compatible dc with a compatible bitmap attached to it. I do this because I am drawing the state off-screen for flicker-free drawing.
I will try drawing direct to the given DC, but I don't feel this will help at all.
Is there anywhere that you can influence the color depth of a window's DC at creation or after?
Simon
|
|
|
|
|
Hmmm, most interesting. In case anyone was interested, I have overcome the problem, but storing the color not as 3 bytes, but as a COLORREF structure.
I am slightly confused, since I thought all the COLORREF structure was is 3 byte values, but if it works, I ain't going to kick it!
Simon
|
|
|
|
|
The problem was obviously in converting the COLORREF to unsigned char values, because that is all they are in the COLORREF
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Soup,
while not having an answer as to why the two colours don't match up I do have this link for you. Try Color Picker, it's free and will show the RGB values for any area of the screen that is under the cursor. Should make it a bit easier than copying into Paint Shop Pro.
Michael Martin
Australia
mjm68@tpg.com.au
"Don't belong. Never join. Think for yourself. Peace"
- Victor Stone
|
|
|
|
|
Thanks for the input guys. Everything is back on track now.
Simon
|
|
|
|
|
does anyone know how to make the OK button the default button in a property page created in my MMC snapin? For now, it defaults to the "Cancel" button.
Tx
Michel
If I am wrong or said something stupid, I apologize in advance
|
|
|
|
|
First of all, If I am wrong or said something stupid, I apologize in advance. Try adding this to CYourPropertySheet:OnInitDialog :
GetDlgItem(IDCANCEL)->ModifyStyle(BS_DEFPUSHBUTTON,0);
GetDlgItem(IDOK)->ModifyStyle(0,BS_DEFPUSHBUTTON); If CYourPropertySheet:OnInitDialog is not available for modification (don't know what those "MMC snapins" are), try moving the code to CYourPropertyPage:OnInitDialog :
GetParent()->GetDlgItem(IDCANCEL)->ModifyStyle(BS_DEFPUSHBUTTON,0);
GetParent()->GetDlgItem(IDOK)->ModifyStyle(0,BS_DEFPUSHBUTTON); Hope it helps.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I try to send messages from my program to Word 2000 but it doesn't resieve them... All is OK with Word 95 & 97... What should i do?...
|
|
|
|
|
I think it is better to put your codes here,then people can help you better.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Hi,
I'm having a difficulty with using the docking windows and how they are laid out. Currently, I can get the windows to layout like in DevStudio:
--------------
| | |
| | |
| | |
| | |
--------------
| |
| |
--------------
I would however like the window on the left to run the full length from top to bottom and have the bottom window have it's left side against the left window, not the client window. Like this:
--------------
| | |
| | |
| | |
| | |
| |----------
| | |
| | |
--------------
Does anyone know if this is possible and how I can make this work?
Thanks in advance,
Craig
|
|
|
|
|
Seems like defining the splitters in the correct order should do it.
Split the main frame into s1 and s2 vertically
--------------
|s1 | s2
| |
| |
| |
| |
| |
| |
--------------
Split s2 into s3 and s4 horizontally
--------------
|s1 | s2
| |
| | s3
| |---------
| | s4
| |
| |
--------------
Split s3 into s5 and s6 vertically
--------------
|s1 | s2 | s2
| | s3 | s3
| | s5 | s6
| |---------
| | s2
| | s4
| |
--------------
split s4 into s6 and s7 vertically
--------------
|s1 | s2 | s2
| | s3 | s3
| | s5 | s6
| |---------
| | s2 | s2
| | s4 | s4
| | s7 | s8
--------------
So An outline view clarifies the nesting of the splitters
s1
s2
s3
s5
s6
s4
s7
s8
Hope this helps,
Bill
|
|
|
|
|
Hi Bill,
Thanks for your response. Yes, I think this would work for splitter windows but will it work for Docking windows as well? I wanted to use docking windows so that the user could move the windows around if they like or make them go away all together.
Thanks again for your help,
Craig
|
|
|
|
|
Sometimes a picture is worth a 1000 words. In this case, I was so busy looking at the picture, I missed the word "docking".
I'm not especially experienced with docking windows. But I would think, if you have the scheme you showed working, this one should work also. It should be a simple re-arrangement of the calls.
|
|
|
|
|
Sometimes a picture is worth a 1000 words. In this case, I was so busy looking at the picture, I missed the word "docking".
If you have the scheme you showed working, this one should work also. I'm not especially experienced with docking windows.
Good luck,
Bill
|
|
|
|
|
I need a Instant Messenger type control that allows different entries (word-wrapped lines) to be in different colours.
I thought about extending CEdit, but couldn't work ou t how to have different colours for different lines
Any suggestions on the best approach to code my own or has anyone done it already?
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
What about RichEdit Control ?
See: RichEdit.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Sometimes you just look too hard!
After tearing my hair out and then finally finding the fact that I needed to call AfxInitRichEdit() I have got a rich edit to partly work.
My question now is: What is the best way to programmatically add text to a rich edit control?
The user doesn't actually edit text into the control directly (it's a messenger type window) so I have used a CString member variable for the Rich Edit Control and then just done a += on that variable to extend the text and then called UpdateData(FALSE). In between I have tried using SetDefaultCharFormat and SetSelectionCharFormat to change the colour, but it's always black. So where am I going wrong?
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Hello all,
I need to split/unsplit the main window in a SDI app using a menu command. I have the splitter window set up in the OnCreateClient function so that it checks a bool flag to decide whether to split or not to split, but I cant figure out how to recall the OnCreateClient function after changing the flag so that it will redraw the desired state.
Any suggestions?
Thanx
I miss the beach!
|
|
|
|
|
Another question that may help me, who calls OnCreateClient, when is it called, and how do I call it?
Landlocked in Atlanta . . .
I miss the beach!
|
|
|
|
|
Hi,
Don't know enough about splitters to really help, but I think chasing the route of 'recalling OnCreateClient' is the wrong way to go. I think MFC calls this to divide the available client area of a frame window up before creation (then it knows how to create the relevant views).
I made a class that could replace views, and it could split an existing view, so I would have thought it was possible to do the opposite.
I am probably wrong, but maybe try:
1. splitting the main window into 1 (sound stupid, but then you have a splitter created and attached to the frame window)
2. divide the main splitter pane up when splitting
3. replace the main splitter pane with just the single view when unsplitting.
This would be how I would approach the problem, though I admit it seems completely unelegant.
Sorry I couldn't be of more help,
Simon
|
|
|
|
|
hi all,
A little background...
My app processes data received on a serial port and creates a graph based on the data received. I do all processing and thread creation (to do the processing) in the Doc class. The Doc class also captures the message sent when the Start button is clicked. I do this because I need to change the views depending on how the user wants to see the data displayed, so a way to keep the threads from getting destroyed when the view changes is to put them in the Doc class (maybe not best solution, but I'm no guru either Anyway, when the start button is clicked I set a bunch of Timers in the Doc class, but the Timer gets used in the View class for updating a graph.
However, the timers are being set, but the view is not updating. I guess the view is not receiving the timers adn thus doesn't even know they have been set. How can I overcome this??
Thanks
-MDP
|
|
|
|