|
Have you set the owner draw style bit when you created the control?
onwards and upwards...
|
|
|
|
|
Yes!
I create the button this way:
hButton = CreateWindow("BUTTON", "X", BS_OWNERDRAW, x, y, 30, 30, hWnd, NULL,(HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL)
|
|
|
|
|
Dont forget the WS_CHILD and WS_VISIBLE styes to make sure the window is shown correctly
Roger Allen - Sonork 100.10016
Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...
|
|
|
|
|
At last!!!
Thanks a lot!!!
|
|
|
|
|
Is there a way to print a .net bitmap with mfc? Thanks
|
|
|
|
|
I have a dialog app and I'm trying to change the background of most of the controls on the dialog. This is the code I'm using, but it isn't changing the controls backgrounds.
if (nCtlColor == CTLCOLOR_STATIC)
pDC->SetBkColor (RGB (255, 255, 255)) This code is in the OnCtlColor function of my dialog class. When I run the program only static controls colors are changing and not my checkboxes or groupboxes. According to my reading CTLCOLOR_STATIC is the same id passed into the function for statics, groupboxes, checkboxes, and a couple other control types. Am I wrong? If so how do I go about changing the background of those controls.
Thanks.
- monrobot13
|
|
|
|
|
Hi,
First, I'm a beginner and I'm doing a little project in MFC and i'm using VS .NET 2003.
I want to put the current month concatenated with an other word as default save name when I save my document. So I want to be able to pass a CString variable to the IDR_MAINFRAME string.
Example: JanuaryDave.sav
I searched on the internet and found nothing on the subject.
Can someone indicate me an article or an example of what I want to do.
Thanks.
David
|
|
|
|
|
I have seen software where the user clicks Update
and the software goes and checks and then downloads
an update and replaces itself with that update. Does
a demo project exist that does something like this?
Please, any response any one can give me will be
greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
the usual question, my application crashes and I can't really figure out where and what I did since yesterday ... and I'm kinda stumped
the only difference is that I "updated" my computer with the windows updater, maybe I need to reinstall VC service pack ( which I will, it doesn't hurt does it ? ). and build using BoundChecker instrumentation, ( but I scrapped the objects files and libs. and rebuild without instrumentation after !)
anyway, it's crashing/asserting in low level routines when allocating (with new ) and freeing (delete) objects; in DEBUG mode; if I continue (F5) it continues without a itch ...
it's an MFC application using Visual C++ 6 sp5.
( in the output window )
HEAP[app.exe]: HEAP: Free Heap block 1919740 modified at 19199e0 after it was freed
I know it's not much, but I can't reduce the error to some line of code that I post here.
any thoughts ?
Much Thanks ...
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I'd say whatever is causing this has been there all along and has decided to appear because of the PC updates, but has nothing to do with them. This is often the case with memory corruption problems unfortunately.
The Debug info is telling you that you are modifing memory that has previously been free'd. This will happen if you use a pointer that has been free'd or you have some erant code (pointers) writing into memory where they shouldn't be.
Break into the debugger when the error occures and dump the memory at the spec'd address and see if its contents means anything to you.
Also after freeing a pointer set it to NULL so you will get an exception if it used again. Make sure all pointers are initialized. Try to move away from using new and delete and look at smart pointers and RAII.
Hope that helps.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Neville Franks wrote:
Break into the debugger when the error occures and dump the memory at the spec'd address and see if its contents means anything to you.
will check this ... I never think of looking in the memory dump.
Neville Franks wrote:
Also after freeing a pointer set it to NULL so you will get an exception if it used again. Make sure all pointers are initialized. Try to move away from using new and delete and look at smart pointers and RAII.
yes I do this and I'm also maintaining old C code and I try to go update as much as I can when I can.
and what are RAII ?
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Maximilien wrote:
and what are RAII ?
"Resource Acquisition Is Initialization". Do a Google search on "C++ RAII" etc.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
i get the handle of a textbox in an opened window using the function
EnumChildWindows(,,)..
after i obtained the handle of this textbox i want to set a specific
string in this textbox.
"HINT" : the function SetWindowText(,) isn't a valid to this task(why?)
more--->
the opened window has a textbox ,a button ,a label;
and when i used the spy++ program of Microsoft tools to get the caption
to each of them after using SetWindowtext(,),i observed that:
the caption of the label is same as the value appears on it<the
caption="" and="" value="" appears="" are="" equal="" to="" each="" other="" the="" string
posted="" by="" setwindowtext()=""> ,BUT
the caption of the textbox isn't the same as the value appears on it
<the value="" is="" nothing="" but="" the="" caption="" equal="" to="" string="" posted="" by=""
setwindowtext()="" function="">then i want an API function to set the value of the textbox not the
caption..
thank you very much for any help..
Sender :Amr abdel mohsen
Email: app_prog@yahoo.com
amr abdel mohsen
|
|
|
|
|
You can't use SetWindowText to set the text of a textbox; SetWindowText sets the text of the window itself.
- Nick Parker My Blog
|
|
|
|
|
No.....
SetWindowText sets the text of _any_ window. Everything in Windows is a window, including simple controls. What the window does when it gets a WM_SETTEXT message varies between what it is.
A popup window (ie a normal window with a caption) sets it's caption
A button sets it's label
A edit control sets it's text
"This function changes the text of the specified window’s title bar, if it has one. If the specified window is a control, the text of the control is changed. For an edit control, the text is the contents of the edit control. For a combo box, the text is the contents of the edit-control portion of the combo box. For a button, the text is the button name. For other windows, the text is the window title."
Etc etc.
Assume when you say "textbox" you mean edit control. What may be causing you grief is the fact that the window handle belongs to another process and SetWindowText first validates the Window (if it's a control) to see if it belongs to the calling process.
Rather than use SetWindowText, do it manually with WM_SETTEXT
LPCTSTR pszTextToSet = "Hello";
::SendMessage(hWndTheControl, WM_SETTEXT, 0, (LPARAM)pszTextToSet);
|
|
|
|
|
Diddy wrote:
SetWindowText sets the text of _any_ window. Everything in Windows is a window, including simple controls. What the window does when it gets a WM_SETTEXT message varies between what it is.
Thanks for correcting me Diddy.
- Nick Parker My Blog
|
|
|
|
|
Hi All,
I am converting a project from VC6 to .net2003 and am running into a compiler error with my (user) message maps. I can't see what is wrong - worked fine in VC6...
Here is the compiler error:
SimParamsDialog.cpp(80) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CSimParamsDialog::* )(void)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
None of the functions with this name in scope match the target type
Here are the message maps:
- these defines are actually in a .h file
#define WM_LOADSENSORSTOGRID WM_USER + 1
#define WM_LOADCALDATATOGRID WM_LOADSENSORSTOGRID + 1
BEGIN_MESSAGE_MAP(CSimParamsDialog, CFormView)
//{{AFX_MSG_MAP(CSimParamsDialog)
ON_BN_CLICKED(IDC_BUTTON_SENDALARM, OnButtonSendAlarm)
ON_WM_TIMER()
ON_MESSAGE(WM_LOADSENSORSTOGRID, OnLoadSensorsToGrid)
ON_MESSAGE(WM_LOADCALDATATOGRID, OnLoadCalDataToGrid)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
and the function(s):
void CSimParamsDialog::OnLoadSensorsToGrid(WPARAM wParam, LPARAM lParam)
{
etc
}
void CSimParamsDialog::OnLoadCalDataToGrid(WPARAM wParam, LPARAM lParam)
{
etc
}
Any ideas? Again this works in VC6...
Thanks
John
|
|
|
|
|
AFAIK your functions have to return an LRESULT, not a void.
LRESULT CSimParamsDialog::onloadSensorsToGrid(WPARAM wParam, LPARAM lParam)
{
...
return 0;
}
LRESULT CSimParamsDialog::onloadCalDataToGrid(WPARAM wParam, LPARAM lParam)
{
...
return 0;
}
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks - that did it!
Worked fine in VC6...odd that it didn't catch that.
John
|
|
|
|
|
Me stupid me need help. Me Inteligence 3 (AD&D 2.0).
Look, I really neeeeed heeeeeeeeelp (F1 F1 F1, bloody button doesn't work .
I have a litle problem of converting std::string to LPSTR or const char *something and vice versa. Heeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeelp???
<<s@t@n>>
|
|
|
|
|
std::string::c_str() will return a const char * .
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
What are some good books for C++ programming (Beginner type stuff)?
|
|
|
|
|
For Visual C++ specifically, Practical Visual C++ 6 is the best I've seen. You can still get it at Amazon.com[^].
Heard in Bullhead City - "You haven't lost your girl - you've just lost your turn..." [sigh] So true...
|
|
|
|
|
I like "The C++ Primer" (3rd) by Stanley Lippman et al.
Maxwell Chen
|
|
|
|
|
If you are only new to C++ (as opposed to being new to programming), I can recommend "Accelerated C++" by Koening/Moo.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|