|
mostafa_pasha wrote:
i know if i wanna use in OpenGL i must swap R with B.
Only if OpenGL stores the bits in RGB. Windows always used BGR.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
|
HI everybody!
I need to know how to set the background color of a view.
I have tried using the 'SetBkColor(COLORREF color)' function but I can't get it to work.
I called the following line in the Draw function in class CView.
pDC->SetBkColor(COLORREF color);
And the background color remains white.
Can anybody tell me what to do?
_Lostris. . .
|
|
|
|
|
you need to "paint" it.
CDC::FillRect or something similir.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
FillRect has seemed to work just fine at first, but when I have to scroll the image, the part of the view that was not visible at the start is still white.
Do you have any other suggestions?
Thanx
_Lostris.
|
|
|
|
|
MSDN says:
"Sets the current background color to the specified color. If the background mode is OPAQUE, the system uses the background color to fill the gaps in styled lines, the gaps between hatched lines in brushes, and the background in character cells. The system also uses the background color when converting bitmaps between color and monochrome device contexts."
So, if you don't write or draw anything, you won't see the desired color.
My suggestion for the 'OnDraw(..)' function:
CRect rect;
GetClientRect(rect);
pDC->FillSolidRect(rect, RGB(255,0,0));
There might be other solutions.
|
|
|
|
|
In a Win32 application you can set the hbrBackground member of the window class structure
typically in "MyRegisterClass".
wcex.hbrBackground = CreateSolidBrush(RGB(255, 0, 0)); // This makes the window red
In MFC you can do something similar in PreCreateWindow.
Due Regards
Mahendra
|
|
|
|
|
How do you set the style for an edit control? I see that I can use the GetStyle function to retreive it's current style, but how do I change the style during run-time? I tried using SetStyle but apparently that isn't a valid approach.
- Aaron
|
|
|
|
|
Use SetWindowLong(hWnd, GWL_STYLE, ...) .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thanks for response. Question: I'm trying to set the ES_PASSWORD style of an edit control..would this be the right way to go about it:
DWORD style = m_wndPassword.GetStyle ();
style |= ES_PASSWORD;
::SetWindowLong (m_wndPassword.GetSafeHwnd (), GWL_STYLE, style); When I run this the password style doesn't appear to be set at all. Any ideas? Thanks again.
- Aaron
|
|
|
|
|
Aaron,
If your using MFC then it's easier to use the ModifyStyle method:
m_wndPassword.ModifyStyle(0, 1, ES_PASSWORD);
Hope this helps,
Andy
|
|
|
|
|
Perhaps you meant this link?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thanks David
must have had a mad cut'n'paste moment.
Cheers,
Andy
|
|
|
|
|
Just tried that Andy, but it wouldn't work either. From the other replies it's looking like I'll need to recreate the control to do this. Thanks for the help though.
- Aaron
|
|
|
|
|
AFAIK some styles could not be changed at runtime: password/left/right/center.
You have to recreate control.
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|
|
grigsoft wrote:
AFAIK some styles could not be changed at runtime...
ES_READONLY is another of those styles. But you can use EM_SETREADONLY instead!
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
monrobot13 wrote:
Any ideas?
Is the control single or multi-line?
It might not even be possible. Read here.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
It's single line.
Looking at the replies above am I going to have to recreate the control since it's looking like some styles can't be changed at runtime? I tried ModifyStyle and it didn't work either. Thanks for the help.
- Aaron
|
|
|
|
|
I got it working, but not by modifying the sytle. I used SetPasswordChar and that seems to have changed the style for me. Not sure if that the best way to do it, but it's working. Thanks to everyone who replied for the help.
- Aaron
|
|
|
|
|
Thanks for the help on my earlier problem.. I have now undertaken rewriting the serial portion of my code to use CreateFile and the like. It's all a bit complicated though, and being new to this, I have a few questions. It starts with overlapping, and also involves WaitCommEvent and GetCommMask. I did a search on the topics and read a few articles that were found, but while they cleared a few things up, they still left me with a few questions unanswered.
First, I understand that SetCommMask allows you to screen for only a few of the events. But after calling SetCommMask to look for only what you want, how does one screen for these events and process them appropriately? I know you can use WaitCommEvent, but in that case, why would you even need GetCommMask? I also need to use overlapping for this program, but I'm not sure how to implement it or even what it actually is (do I need to use the overlapped structure at all?).
I was able to find this piece of example code on MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/monitoring_communications_events.asp
I do not fully understand how it operates, though.
Also, this article was very helpful, to a point: http://www.codeproject.com/system/serial_com.asp
Where I got lost was the huge block of code where he uses the OVERLAPPED structure and the Threadfn function, after which he writes "If you understood the above code , you will understand the whole of this article and the source code provided." Gulp.
As always, the help is very much appreciated.
|
|
|
|
|
From this link: Configuring a communications resource:
#include <windows.h><br />
<br />
int main(int argc, char *argv[])<br />
{<br />
DCB dcb;<br />
HANDLE hCom;<br />
BOOL fSuccess;<br />
char *pcCommPort = "COM2";<br />
<br />
hCom = CreateFile( pcCommPort,<br />
GENERIC_READ | GENERIC_WRITE,<br />
0,
NULL,
OPEN_EXISTING,
0,
NULL
);
pcCommPort is declared as a pointer to a character, which is assigned "COM2". How does this make sense? A char cannot be more than one character in length, right? Upon testing, trying to do *pcCommPort = "COM3" later in the program does indeed yield "error C2440: '=' : cannot convert from 'char [5]' to 'char'" which actually makes sense. So why is that same assignment statement allowed upon declaration?
Also, if at some point, I need to change the COM port to say, COM3, how would I accomplish that? *pcCommPort = "COM3" did not work, as I mentioned.
Thanks in advance.
|
|
|
|
|
"COM2" is a constant null terminated string allocated somewhere by the compiler. It's reasonable to set a char * to point to its first character. But really it should be a const char * since the value of the string should not be changed.
Try writing pcCommPort = "COM3" , now you're setting the value of pcCommPort to the address of "COM3". Previously you were trying to set what pcCommPort pointed at (in this case presumably the constant string "COM2") to your new string. Which isn't what you intended.
Paul
|
|
|
|
|
Thanks Paul -- that was it! I don't know why I didn't catch it myself.
Still looking for some clarification and answers about my original post... your help is greatly appreciated.
|
|
|
|
|
I'm now down to the point where I have the code written for everything up to where I understand -- meaning, the WaitCommEvent part is the only part that needs completing.
Any help with this?
|
|
|
|
|
How can I check if application X is running ?
I’m writing an Update tool for my application and I need the program to
wait until the application quits before continuing.
I don’t think I can use FindWindow since the Title text of the application is not static.
/Mathias
|
|
|
|