|
Hi.
What is the best way to update the background color of one or more static/edit control in a dialog box? For example, I have a static control in a dialog box that I use to depict font color. If the user sets the font to have green color, than the user will see a static control that is green. Initially, I use WM_CTLCOLOR to update the color of the static control. The problem is it only works when the dialog first initializes. Once it has been initialized, I cannot figure out how to update the static control after the user have selected a different color. I try PostMessage(WM_CTLCOLOR, 0, 0), however, the program crashes. It seems ON_WM_CTLCOLOR only works when the dialog is initialized.
Here is the code.
-----
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd->GetDlgCtrlID() == IDC_STATICCOLOR)
{
// m_pBrush is a pointer to a brush object I use containing the
// font color I the user wants
if (m_pBrush != NULL)
{
delete m_pBrush;
m_pBrush = NULL;
}
m_pBrush = new CBrush(m_Color);
hbr = static_cast<hbrush>(m_pBrush->GetSafeHandle());
}
-----
Please post if you have any idea on a possible solution.
Thanks,
Kuphryn
|
|
|
|
|
Have you tried invalidating the control in order to force a repaint. Better yet you could force a repaint of your entire dialog window with this:
RedrawWindow(hDlg, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_ERASENOW | RDW_REDRAWNOW | RDW_ALLCHILDREN);
This will force your window and all of its children to redraw, which should generate WM_CTLCOLOR messages for each of the controls.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thanks.
Your first pointer of invalidating was correct. The solution is to call Invalidate(). It repaints everything as designed.
I would have never thought of using Invalidate
(). I have always thought that it calls OnDraw() or
OnPaint().
Thanks to jimmy leung of MSDN Newsgroups for that solution too.
Kuphryn
|
|
|
|
|
How can I eliminate the "gangload area" from an EXE (FON) file I am creating?
Is there a flag that should be used with TLINK or MS LINK? Or is there an appropriate entry
that should be placed in the .DEF file?
EXEHDR.EXE reports that there is always a gangload area created starting at 0x200 of size 0x600.
This area substantially increases the file size to no avail.
gjr
|
|
|
|
|
the cfiledialog only can return a file path ,but i want rechive the directory path. how to do it? thanks.
|
|
|
|
|
SHBrowseForFolder
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
I want to parse the HTML page using MSHTML. before I can parse, so I use IPersistMoniker to load URL.
Then the problem arises, if the URL is not existed. IPersistMoniker still load it, and said it had completed. how can tell the loaded pages is for non-existed URL from correct URL ?
|
|
|
|
|
Have you looked at IsValidURL ?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi there:
I have a compiled DLL created with C++. Is there a way to look inside to see what it's made off?
Thanks
A reasonable man adapts himself to the world. An unreasonable one persists, trying to adapt the world to himself. That is why all the progress in the world depends on the unreasonable men.
|
|
|
|
|
You can partly do it: Start VC++ and choose open file. In the dialog, choose All Files, and in the Open As combo, choose Resource. I leave the rest as an exercise...
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Following tools are useful
1. Depends.exe Get the latest from http://www.dependencyviewer.com
2. Dumpbin.exe for disassembling
I wish I knew an equivalent of Anakrino that would decompile x86 code.
|
|
|
|
|
Personally whenever I find the need to do this I use Sourcer from "V Communications".
new window www.v-com.com
same window www.v-com.com
|
|
|
|
|
I wish I knew an equivalent of Anakrino that would decompile x86 code.
I've never heard of Anakrino, but the de-facto serious disassembler for x86 would be IDA - The Interactive DisAssembler sold by DataRescue.
|
|
|
|
|
Rama Krishna wrote:
1. Depends.exe Get the latest from http://www.dependencyviewer.com
Actually it is Dependency Walker
Best regards,
Alexandru Savescu
|
|
|
|
|
Why is it that if I do a atoi on a string it trims off everything after the "."?
CString strDollar = "6.24";
int nDollar = atoi(strDollar);
nDollar then equals 6
is there another way i can do this and keep the .24?
Thanks
|
|
|
|
|
|
tnx
|
|
|
|
|
nDollar should be a float or a double. Any decimal places in an int will get chopped off.
|
|
|
|
|
MS doc says to change Network Neighborhood Icon
Modify key HKEY_CLASSES_ROOT\CLSID\{208D2C60-3AEA-1069-A2D7-08002B30309D}\
DefaultIcon = shell32.dll,17
When I change default "shell32.dll,17" to "shell32.dll,7", it does not change icon on Win XP and Win2K.
Any thoughts?
|
|
|
|
|
My guess is that it's cached in ShellIconCache. Maybe UpdateWindow(0); can help.
If all else fails you could try using Spy++ on the desktop SysListView32 and see what happens when you manually change the icon.
|
|
|
|
|
ok... my problem accures in this line of code:
strcpy(M_ID, STID);
error C2664: 'strcpy' : cannot convert parameter 1 from 'char' to 'char *'
M_ID is a member of my class ID, and
STID is a char created within the function that this code lies.
i dont understand why it says char to * char because, non of them are pointers.
thanks for your help!
~SilverShalkin
|
|
|
|
|
strcpy requires char* as arguements to the function.
So if STID is a plain char, the compiler will attempt to convert the char to a char* to fit into the arguement in strcpy. Since there is no conversion for the compiler to do this, it reports and error.
You will need to use a char*.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
ok... so i would have to have a pointer on the second one like:
strcpy(M_ID, *PID);
*PID points to SID which is the intake of info for the function.
or would i do...
strcpy(M_ID, PID); //without derefrencing it?
Thanks!
~SilverShalkin
|
|
|
|
|
You do not want to dereference it. But once again, PID must be a char*.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
i changed it to what you said, and now i got this error pop up:
error C2664: 'strcpy' : cannot convert parameter 1 from 'char' to 'char *'
what does it mean by parameter 1?
thanks!
~SilverShalkin
|
|
|
|