|
Example code probably won't help but I can walk through the steps to reproduce the problem.
I'm using Visual Studio 2003 .Net
- Create new MFC Application, select application type Dialog based.
- In the class view, using the wizard create a new class with a base class of CButton, I called mine MyButton.
- in the main dialog create a new button, right click and "Add Event Handler" choose the Message type: BN_CLICKED and the class as MyButton.
- in the handler OnBnClickedButton1 add MessageBox("hello");
- run application
- click button, nothing happens
however if you added the Event Handler to the main dialog class created by the wizard, then everything works fine.
Ideas?
Thanks
Hua-Ying
|
|
|
|
|
did you put a break point in your handler ?
me think it's the MessageBox that simply doesn't show.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hmm. I'd say the button press must be notified to the parent of the button, in this case the dialog.
Notice that the event is called "BN_CLICKED". the "N" in "BN_" usually means "notification", in which case, the button's parent is notified.
HTH
Bikram Singh
I believe we should all pay our tax with a smile. I tried - but they wanted cash.
|
|
|
|
|
Use message reflection. See technical note 62 in MSDN. Search for TN062
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
In the message map for MyButton , add the following:
ON_CONTROL_REFLECT(BN_CLICKED, OnBnClickedButton1) and remove the ON_BN_CLICKED() statement.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks, this is exactly what I'm looking for!
|
|
|
|
|
What class did you derive from? What event are you wanting to handle?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
See my response to Jamie please, that should be enough to completely reproduce the problem.
Thanks
Hua-Ying
|
|
|
|
|
IIRC, I think you will need to use "reflection" to make this work. There is usualy a weird message handle for classes like button that allows them to trap their own click messages.
In VS 7, and I think VS 6 did it this way too, the message you want to trap in the wizards looks something like:
=BN_CLICKED
And the message map entry will be something like:
ON_CONTROL_REFLECT(BN_CLICKED, OnBnClicked)
Hope this helps.
An expert is somebody who learns more and more about less and less, until he knows absolutely everything about nothing.
|
|
|
|
|
Thanks for everyone's help!!
For anyone else who's having the same problem, one last thing you must do before this solution will work is to add a variable in you main dialog class so that when it loads your control it will use the subclass for the control instead of the original.
Details: using the class wizard generate a new variable with your subclass type, click the control check box (VS 2003 .Net) so that DDX_Control will update the value.
You can also follow Chris Maunder's great tutorial on subclassing controls:
tutorial
Hua-Ying
|
|
|
|
|
Hello Dear
I want to convert an character string into UNICODE(Wide Character), I found function for it in MSDN it's called MultiByteToWideChar()...But don't know how to use it ..? Pls any one can do it for me...?
Suppose I have a string say : char *sString ="XYZ"; and want to convert it using this function then ..?
Thank You...
MacGlen
|
|
|
|
|
Straight from MSDN:
WCHAR wszUserName[256];
char *sString = "XYZ";
MultiByteToWideChar(CP_ACP,
0,
sString,
strlen(sString) + 1,
wszUserName,
sizeof(wszUserName) / sizeof(wszUserName[0]));
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Dear David Crow
Thank You very much for my answer.
It's really wroking very find...
I againg like to thank you.
Bye
Amarelia Maehsh
|
|
|
|
|
Hi,
I have several SplitterWnd with dialogbox-based FormView in my application. For a good layout i need the size in pixel of the dialogboxes (generated with the ressourceeditor) as early as possible to arrange the splitter windows.
Please help me!
|
|
|
|
|
Rolf Faßler wrote:
I have several SplitterWnd with dialogbox-based FormView in my application.
How many CSplitterWnd controls are there? Is the view in each pane derived from CFormView ?
What are you wanting the size of the panes to be based upon?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I have up to 11 SplitterWnd in my application, the panes in four of them are derived from CFormView.
|
|
|
|
|
Rolf Faßler wrote:
I have up to 11 SplitterWnd in my application...
So does this mean that you have 22 panes (I'm assuming that there are two panes per splitter window)?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Greets,
i need a idea, how i can convert a sepcific (graphic) file to a bitmap witch is based in memory.
Reason is: i can't write out a bitmap-file, and load it after writting, cause the file information have to be secure. After the bitmap staying in memory i can load, show, and destroy it. I think so?
I know the bitmap file format, and i have the informations from the specific file to fill bitmap-structure-components. So what i don't know is: witch interface can i use to open and get the specific file informations, how i can load the packed bitmap, after i fill the structure, into the memory, and how i can display this packet bitmap.
thanks for every answer
codefire
|
|
|
|
|
a BMP file is simply a BITMAPFILEHEADER followed by a DIB. so, just skip the BITMAPFILEHEADER and call StretchDIBits to display the DIB.
Software | Cleek
|
|
|
|
|
thx it run's.
|
|
|
|
|
I get this error:
'__thiscall CFile::CFile(const char *,unsigned int)' : cannot convert parameter 1 from 'const char *(void) const' to 'const char *'
when I try to do :
CFile filePort(m_outputFileName[0].c_str, CFile::modeRead);
m_outputFileName[0] is a std::string.
Will I have to strcpy m_outputFileName[0] into a char temp[256] and put that into CFile?
I'm not sure how to make the std::string behave for the CFile. Is there a simpler way?
Thanks,
sb
Added:
I get the same error if I do:
char file1[256];
strncpy ( file1, m_outputFileName[0].c_str, 256);
|
|
|
|
|
c_str()
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Aaargh! Havent dealt with std::strings much....thats my poor excuse.
Thanks so very much,
sb
|
|
|
|
|
Hi Guys,
How Can I convert a CString to a T_String.
My T_String is a typedef defined as follows.
typedef std::wstring T_String;//wstring,co's my project is unicode defined.
Thanks......
|
|
|
|
|
Just curious....
Why are you doing that? CString has already unicode support.
Jaime
|
|
|
|