|
Hi Steve,
The problem has to do with the fact that when CDialog tries to create a dialog window from the resource template internally it does by calling ::CreateWindowEx() function. The most important argument in this function is the name of the window class (like "Static" for static control or "Edit" for edit control). It is required that before window is created its window class must be registered. MFC does it internally for common controls but not for rich edit control which implementation resides in different dll. So when you call DoModal() function the internal Windows implementation will fail to create the rich edit control and therefore the creation of the dialog will fail as well.
Now how to fix the problem.
You just have to load the dll that contains rich edit control implementation in your InitInstance() function:
HINSTANCE hRichEdDLL=::LoadLibrary(_T("RICHED32.DLL");
if(g_hRichEdDLL==NULL)
TRACE(_T("Cannot load library to display RichEditTextControl"));
Regards,
Andrei Zenkovitch
Dundas Software
P.S. I assumed you were using MFC. If it is not the case then above mentioned explanations are still valid.
==================
The original message was:
I'm using VC++5. I find that when I use the resource editor to put a Rich Edit control in a dialog that is used either as part of a property sheet or as a dialog started from a menu option that the DoModal dialog callreturns -1 indicating that the box could not be created. (The same thing happens in VC++6). I searched the help and found no mention of any such limitation - it seems logical to be able to do it as the control is in the toolbar in the resource editor. I guess I must be doing something wrong. Any ideas?
Steve
|
|
|
|
|
Andrei,
Thank-you; this seems to explain the other advice I received to include AfxInitRichEdit() in InitInstance.
Steve
==================
The original message was:
Hi Steve,
The problem has to do with the fact that when CDialog tries to create a dialog window from the resource template internally it does by calling ::CreateWindowEx() function. The most important argument in this function is the name of the window class (like "Static" for static control or "Edit" for edit control). It is required that before window is created its window class must be registered. MFC does it internally for common controls but not for rich edit control which implementation resides in different dll. So when you call DoModal() function the internal Windows implementation will fail to create the rich edit control and therefore the creation of the dialog will fail as well.
Now how to fix the problem. You just have to load the dll that contains rich edit control implementation in your InitInstance() function:
HINSTANCE hRichEdDLL=::LoadLibrary(_T("RICHED32.DLL"); if(g_hRichEdDLL==NULL) TRACE(_T("Cannot load library to display RichEditTextControl"));
Regards, Andrei Zenkovitch Dundas Software
P.S. I assumed you were using MFC. If it is not the case then above mentioned explanations are still valid. ================== The original message was: I'm using VC++5. I find that when I use the resource editor to put a Rich Edit control in a dialog that is used either as part of a property sheet or as a dialog started from a menu option that the DoModal dialog callreturns -1 indicating that the box could not be created. (The same thing happens in VC++6). I searched the help and found no mention of any such limitation - it seems logical to be able to do it as the control is in the toolbar in the resource editor. I guess I must be doing something wrong. Any ideas?
Steve
|
|
|
|
|
How can you stop a modeless dialog box from being deleting, when the escape key is pressed. I tried trapping the VK_ESCAPE message, but it still got destroyed. Can anyone help me?
|
|
|
|
|
You have to override the OnCancel function of the dialog box.
|
|
|
|
|
If you dont't want to overwrite all the func (OnCancel, OnOk, ... (and don't forget Alt+F4), you can overwrite the PreTranslateMessage func and try catching ESC, Return ...
BOOL CSelectToolDlg::PreTranslateMessage(MSG* pMsg)
switch (pMsg->message)
{
case WM_KEYDOWN:
switch (pMsg->wParam)
{
case VK_RETURN:
pMsg->wParam = 0;
break;
case VK_ESCAPE:
pMsg->wParam = 0;
break;
}
break;
Hope this helps
erni
|
|
|
|
|
Is there any way to emulate or do something similar to a VB control array in VC++?
Thanks,
Marc
|
|
|
|
|
How does one make static text (in)visible in VC++? I can't find this out in all of the books I have or the MSDN. I'm looking for something similar to the VB object.visible property in VC++.
Thanks,
Marc
|
|
|
|
|
Marc,
I think you are looking for ShowWindow function. It is a member of CWnd, so you can be sure that all window controls have it. Use it as:
ShowWindow( SW_SHOW ); -- to make a window visible
ShowWindow( SW_HIDE ); -- to hide a window
Peter Zajac
Dundas Software
==================
The original message was:
How does one make static text (in)visible in VC++? I can't find this out in all of the books I have or the MSDN. I'm looking for something similar to the VB object.visible property in VC++.
Thanks,
Marc
|
|
|
|
|
Just do : GetDlgItem(IDC_STATIC_IDNNN)->ShowWindow(SW_HIDE); of course for this each one of the items u wish to hide should have a unique id.
cheers
Rajiv
==================
The original message was:
How does one make static text (in)visible in VC++? I can't find this out in all of the books I have or the MSDN. I'm looking for something similar to the VB object.visible property in VC++.
Thanks,
Marc
|
|
|
|
|
Is there a "code keeper / code bank" type program written in VC++ w/source code available?
Thanks,
Marc
|
|
|
|
|
I don't exactly know what you're referring to but it sounds an awful lot like a DLL. In other words, when you have some common code that other apps may need to use, you put it in a DLL and presto.
Alvaro
==================
The original message was:
Is there a "code keeper / code bank" type program written in VC++ w/source code available?
Thanks,
Marc
|
|
|
|
|
This must be easy BUT.....
I've tried to change the font on a single CEdit box in a dialog. I've used the following code....
CFont m_Font;
m_Font.CreateFont(.........);
GetDlgItem(CEDIT_ID)->SetFont(&m_Font);
Now this "sort of" works. The font is changed BUT the line size of the CEdit is not changed accordingly so the lines below overlap lines above.
Can someone please sell me how this can be done??
Thanks in advance
Jeremy Davis
|
|
|
|
|
Hi Jeremy!
I think your have problems because you are creating font in the local variable and as soon as it go out of scope the font is destroyed.
The lifetime of the CFont object should be the same as your edit control. The best thing to do this is to add a CFont variable to your dialog class.
Regards,
Alex Gorev,
Dundas Software.
==================
The original message was:
This must be easy BUT.....
I've tried to change the font on a single CEdit box in a dialog. I've used the following code....
CFont m_Font; m_Font.CreateFont(.........); GetDlgItem(CEDIT_ID)->SetFont(&m_Font);
Now this "sort of" works. The font is changed BUT the line size of the CEdit is not changed accordingly so the lines below overlap lines above.
Can someone please sell me how this can be done??
Thanks in advance
Jeremy Davis
|
|
|
|
|
Thanks! I'll try it and let you know.
==================
The original message was:
Hi Jeremy!
I think your have problems because you are creating font in the local variable and as soon as it go out of scope the font is destroyed.
The lifetime of the CFont object should be the same as your edit control. The best thing to do this is to add a CFont variable to your dialog class.
Regards, Alex Gorev, Dundas Software.
================== The original message was: This must be easy BUT.....
I've tried to change the font on a single CEdit box in a dialog. I've used the following code....
CFont m_Font; m_Font.CreateFont(.........); GetDlgItem(CEDIT_ID)->SetFont(&m_Font);
Now this "sort of" works. The font is changed BUT the line size of the CEdit is not changed accordingly so the lines below overlap lines above.
Can someone please sell me how this can be done??
Thanks in advance
Jeremy Davis
|
|
|
|
|
Doh! The easiest ones are sometimes the hardest to find!
==================
The original message was:
Hi Jeremy!
I think your have problems because you are creating font in the local variable and as soon as it go out of scope the font is destroyed.
The lifetime of the CFont object should be the same as your edit control. The best thing to do this is to add a CFont variable to your dialog class.
Regards, Alex Gorev, Dundas Software.
================== The original message was: This must be easy BUT.....
I've tried to change the font on a single CEdit box in a dialog. I've used the following code....
CFont m_Font; m_Font.CreateFont(.........); GetDlgItem(CEDIT_ID)->SetFont(&m_Font);
Now this "sort of" works. The font is changed BUT the line size of the CEdit is not changed accordingly so the lines below overlap lines above.
Can someone please sell me how this can be done??
Thanks in advance
Jeremy Davis
|
|
|
|
|
I would like to know how I can execute another program
from within my MFC apps.
|
|
|
|
|
To execute another program from within your MFC/SDK application you can use 'ShellExecute'.
==================
The original message was:
I would like to know how I can execute another program from within my MFC apps.
|
|
|
|
|
==================
The original message was:
To execute another program from within your MFC/SDK application you can use 'ShellExecute'.
================== The original message was: I would like to know how I can execute another program from within my MFC apps.
Thanks, This is what I needed
|
|
|
|
|
==================
The original message was:
I would like to know how I can execute another program from within my MFC apps.
|
|
|
|
|
==================
The original message was:
I would like to know how I can execute another program from within my MFC apps.
I recommend using the _exec function or any of the variations of it. Look it up in C++ help since the command instructions are extensive.
Best wishes for the holday!
|
|
|
|
|
STARTUPINFO si;
PROCESS_INFORMATION pi;
BOOL bResult;
// Initialise the STARTUPINFO structure
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOW;
bResult = ::CreateProcess(NULL, // no executable module name (use command line)
"WordPad.Exe", // command line, file name in same directory as the DLL
NULL, // process handle not inheritable
NULL, // thread handle not inheritable
FALSE, // handle inheritance
0, // no creation flags
NULL, // use parent's environnement block
NULL, // use parent's starting directory
&si, // pointer to STARTUPINFO structure
&pi); // pointer to PROCESS_INFORMATION structure
if (!bResult)
{
TRACE("Can't start WordPad.Exe\n");
}
regards, Jean-Claude.
|
|
|
|
|
I use a dropdown combobox. By runtime the combobox style should be changed from CBS_DROPDOWN to CBS_DROPDOWNLIST. How can I do that.
Thank you for your help
Bernhard
|
|
|
|
|
Hi !
You can't change the style of the combo box after creating because different windows are created inside the control depending on the style.
For combo boxes created with the CBS_SIMPLE styles, the ComboBox window is the parent of the edit control and the list box that is always displayed on the screen.
Combo boxes created with the CBS_DROPDOWNLIST style have no edit control. The region of the combo box that displays the current selection is in the ComboBox window itself.
For combo boxes created with the CBS_DROPDOWN style, three windows are created. The combo box edit control is a child of the ComboBox window.
What I suggest you to do is either destroy and recreate control with different style or have two controls in the same position and hide/show one of them.
Regards,
Alex Gorev,
Dundas Software.
==================
The original message was:
I use a dropdown combobox. By runtime the combobox style should be changed from CBS_DROPDOWN to CBS_DROPDOWNLIST. How can I do that.
Thank you for your help
Bernhard
|
|
|
|
|
I'm not 100% positive...but I believe you can... try this in your InitDialog function
GetDlgItem(IDC_YOURCOMBO)->ModifyStyle(CBS_DROPDOWN,CBS_DROPDOWNLIST,0);
You may or may not need a :: in front of the GetDlgItem...whichever will give you a CWnd.
Carole
==================
The original message was:
Hi !
You can't change the style of the combo box after creating because different windows are created inside the control depending on the style.
For combo boxes created with the CBS_SIMPLE styles, the ComboBox window is the parent of the edit control and the list box that is always displayed on the screen.
Combo boxes created with the CBS_DROPDOWNLIST style have no edit control. The region of the combo box that displays the current selection is in the ComboBox window itself.
For combo boxes created with the CBS_DROPDOWN style, three windows are created. The combo box edit control is a child of the ComboBox window.
What I suggest you to do is either destroy and recreate control with different style or have two controls in the same position and hide/show one of them.
Regards, Alex Gorev, Dundas Software.
================== The original message was: I use a dropdown combobox. By runtime the combobox style should be changed from CBS_DROPDOWN to CBS_DROPDOWNLIST. How can I do that.
Thank you for your help
Bernhard
|
|
|
|
|
Hi Carole!
Modifying the style of the combo box will work only if you do this before the window creation. After that it will not work.
Alex Gorev,
Dundas Software.
==================
The original message was:
I'm not 100% positive...but I believe you can... try this in your InitDialog function
GetDlgItem(IDC_YOURCOMBO)->ModifyStyle(CBS_DROPDOWN,CBS_DROPDOWNLIST,0);
You may or may not need a :: in front of the GetDlgItem...whichever will give you a CWnd.
Carole
================== The original message was: Hi !
You can't change the style of the combo box after creating because different windows are created inside the control depending on the style.
For combo boxes created with the CBS_SIMPLE styles, the ComboBox window is the parent of the edit control and the list box that is always displayed on the screen.
Combo boxes created with the CBS_DROPDOWNLIST style have no edit control. The region of the combo box that displays the current selection is in the ComboBox window itself.
For combo boxes created with the CBS_DROPDOWN style, three windows are created. The combo box edit control is a child of the ComboBox window.
What I suggest you to do is either destroy and recreate control with different style or have two controls in the same position and hide/show one of them.
Regards, Alex Gorev, Dundas Software.
================== The original message was: I use a dropdown combobox. By runtime the combobox style should be changed from CBS_DROPDOWN to CBS_DROPDOWNLIST. How can I do that.
Thank you for your help
Bernhard
|
|
|
|