|
GetDlgItem(IDC_MYCONTROL)->SendMessage()
I'm drinking triples, seeing double and acting single
|
|
|
|
|
Hi all,
i have a modal dialog. i've created a button in run-time using new operator to CButton class, and then Create;
my question is i want the dialog to catch the pressing of the button or other buttons created at run-time for that matter.....
how to do that???
i know i need to use reflection or something like that.. i would like to see some sample code ....
Thanks in advanced
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
It's to my understanding that message reflection is MFC compile time only.
If your creating windows dynamically I don't think there is a way to map handlers using macros So I would suggest probably using OnCommand() and using an if statement:
MyDialog::OnCommand( WPARAM wParam, LPARAM lParam )
{
if(LOWORD(wParam) <= IDC_DNYCTRL_FIRST && LOWORD(wParam) >= IDC_DNYCTRL_LAST)
}
HTH
Cheers
I'm drinking triples, seeing double and acting single
|
|
|
|
|
Hockey wrote:
if(LOWORD(wParam) <= IDC_DNYCTRL_FIRST && LOWORD(wParam) >= IDC_DNYCTRL_LAST)
Shouldn't this be:
if(LOWORD(wParam) <= IDC_DNYCTRL_LAST && LOWORD(wParam) >= IDC_DNYCTRL_FIRST)
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Something like that
I must have typed it with my eyes closed
I'm drinking triples, seeing double and acting single
|
|
|
|
|
Add a button on the dialog use dialog editor, and appoint the same ID as you call CButton::Create.Than you can add message handler for that button.After a the message handler has been added, you can delete that button on the dialog, and create it at run-time.
Note:using the same ID is crucial.
This is very tricky techniques.
|
|
|
|
|
Hi Yaron,
wouldn't help you to create your button within the dialog editor and hide/show it with
ShowWindow(TRUE/FALSE)?
Bunburry
|
|
|
|
|
Hi, I've encoutered the following problem:
I'm using 2 machines: XP pro sp1 and Win2K sp4. Both are English OS with all language support installed (east asia, Hebrew, Arabic, Thai, the works). Both machines have Office XP installed (which installs additional fonts).
I created a simple MFC exe (unicode) with a single edit box (not rich-edit). The dialog's font is the generic-type "MS Shell Dlg". I have a small piece of text - each line in a different language (5 lines): English, Hebrew, Russian, Japanese and Indic. I keep the text in an RTF file.
Anyway, I run the app on my XP pro and I paste the 5 lines from Word into the Edit box. I see everything great.
However, when I do the same in Win2K, I see everything except the Indic text (I see some black vertical bars instead).
I don't know if it has anything to do with it, but I know that RICH-EDIT controls don't support Indic before XP Pro sp1, but I was never aware of anything regarding common controls such as a simple edit box. I couldnt' find any docs about the common controls.
p.s. When I changed the font from MS Shell Dlg to Arial Unicode MS, everything showed great, but that's bad practice since I can't distribute this font commercially with my app (it only comes with office 2K or higher), and it's also bad to hardcode a font face name in the app.
Does anyone have a clue how to support Indic in edit boxes (as well as the other languages at the same time) without specifying
a font face name in the app and without the user having to select fonts?
Thanks.
/=/=/=/=
Deus
/=/=/=/=
|
|
|
|
|
Hi, I want to open a file in a folder which is different from the folder where the application resides. I used fopen but the file still is created in the same place.How to change the destination of the file?
Thanks,
Deepak Samuel
|
|
|
|
|
Did you try to simply state the full path to the file in the 'fname' argument to fopen? Something like:
"c:\\dir1\\dir2\\myfile.ext"
/=/=/=/=
Deus
/=/=/=/=
|
|
|
|
|
Post the code that creates the new file.
Kuphryn
|
|
|
|
|
Well... in our application, we've changed the resolution dynamically, when the resolution was too small to show the whole dialog.
In WinNt4.0 there weren't any problems, in Win2k strange things occur (it seems that the WM_DISPLAYCHANGE message isn't sent.. cause the toolbar stays at the position [looks like it is floating around on the screen)
the code
[pre]
void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
CFrameWnd::OnActivate(nState, pWndOther, bMinimized);
// TODO: Add your message handler code here
if(nState == WA_INACTIVE)
ChangeDisplaySettings(NULL, 0);
if(nState != WA_INACTIVE){
DEVMODE* pDevMode;
pDevMode = new DEVMODE;
pDevMode->dmSize = sizeof(DEVMODE);
// dm.dmDriverExtra = 800;
if(EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS, pDevMode )){
DWORD dw_width = pDevMode->dmPelsWidth;
DWORD dw_height= pDevMode->dmPelsHeight;
if(dw_width < (unsigned int)pParameter->GetInt ("XPixel")){
pDevMode->dmPelsWidth = pParameter->GetInt ("XPixel");
pDevMode->dmPelsHeight = pParameter->GetInt ("YPixel");
long l = ChangeDisplaySettings(pDevMode, 0);
}
delete pDevMode;
}
}//if(!WA_INACTIVE
}
[/pre]
Any ideas ?
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
Hi,
I have created an Explorer extension to provide a custom column.
This column is quite happy being turned on and off on a per folder basis in Explorer - I can tell any particular folder whether to display the column.
Now, in my application, I want to do a file open dialog (CFileDialog, GetOpenFilename() etc).
This is all ok and after no small effort I have managed to get this dialog to use the 'Report' view by default for the ListView control.
The problem is that the dialog only shows the default columns (Name, Size, Type etc...) and pays no attention to the individual folder settings - thus my column is not displayed even if the particular folder is supposed to be showing it.
I can select the column to be displayed in a folder but then if I browse to another and return the column settings have disappeared.
If I tell every folder to display the column (Tools-Folder Options-View-Like Curent Folder) then the column wil be displayed in my file open dialog. However, I don't want this column to be displayed for every single folder in Explorer (I intend adding quite a few more columns which show information inappropriate to most folders).
I know about the SHELLDEF_View and SysListView32 classes that implement the ListView control and can get to the interfaces below:
IID_IShellFolder2
IID_IShellIcon
IID_IPersistFolder3
IID_IShellIconOverlay
None of these interfaces appear to have methods that allow me to manipulate the columns shown. I know I can manually add columns with ListView.InsertColumn() but then there is no way of populating the control properly (or is there?) and it seems to blow up if I try and change views.
Does anyone know of a way of telling the control which columns to show, and to get it to remember which columns are to be shown. I know it can be done (Visual Studio.net has a dialog such as I need but it's quite possible that that uses it's own which just happens to be very similar to the standard dialog) but how?
I really cannot believe that one of the most used dialog boxes in the known universe is such a pain in the ar** to use (well obviously I can but even so...).
Do I have to implement my own IShellView + place it over the top of the standard one? This would be annoying due to having to implemnent the sorting, right click etc.
Thanks for any help on this particularly matter because it's driving me up the wall : )
Rick Dangerous
|
|
|
|
|
I have been struggling over this and I have come to the conclusion that the CRichEditCtrl is NOT a true WYSIWYG control.
To see this, create a control that is say 4 inchs wide by 1 inch deep. Now use the SetTargetDevice to attach the control to your default printer, set the font of the control to be 12 pt Times New Roman. The only thing that SetTargetDevice will do is have the control look like it will print for the word break. It will not make the text within the control look like it will when it prints (spacing wise).
Now draw a rectangle around the control (have the rectangle several pixels bigger in each direction from the control, since the control will overwrite the rectangle on the screen if they are the same size.
If you type some text into the control, when it wraps, you may notice that where the text wraps and the area to the end of the control seems too big and could contain some text. When I first saw this, I was wondering if I didn't correctly calculate the width for the SetTargetDevice. But, when I printed, the text went up to the end of the control next to the right side of the rectangle (well, not all the way).
Now if anyone can show me how to make the text spacing within the control look like it will print, please do!
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
i want to add unicode support to my project.
for example i changed atoi to _ttoi.
please tell me which macro is equivalent with atof.
|
|
|
|
|
|
you don't have a ready-made macro, but you can use _wtof instead of atof. Define your own macro to deal with it.
/=/=/=/=
Deus
/=/=/=/=
|
|
|
|
|
How to abort reading operation on blocking socket? WSAAsyncSelect doesn't work.
|
|
|
|
|
What do you mean WSAAsyncSelect does not work? WSAAsyncSelect is a non-blocking I/O model.
Kuphryn
|
|
|
|
|
He means following situation. There are 2 threads. One thread sets the socket to blocking state and starts to receive data. Let the next recv() function blocks the socket. The second thread wants to terminate this operation. What should it do? Calling AssyncSelect() from the second thread doesn't set the socket back to non-blocking mode.
|
|
|
|
|
All is OK now. Sockets set back to non-blocking mode after a few seconds - use select()
|
|
|
|
|
Hi, how do I use the RichEdit 4.1 control? I have XP sp1 and the msftedit.dll file exists on my machine. I don't know the class name I should use... RICHEDIT20W or RICHEDIT20A doesn't work.
/=/=/=/=
Deus
/=/=/=/=
|
|
|
|
|
sagmam wrote:
how do I use the RichEdit 4.1 control?
The same way you'd have used the RE library in the past. Each one is a superset of the previous one (with the exception of new functionality, only the name of the DLL changes). After calling LoadLibrary() , you can then use the API just like normal. Assuming you already knew all that, the different between RICHEDIT20W and RICHEDIT20A is that the former is for Unicode and the latter is for ANSI.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
That's what I thought too... I used the Unicode version of RE (I'm developing an international app) by manually entering RICHEDIT20W in the .RC file of VStudio. I loaded msftedit.dll in my InitInstance(), and nothing happened - the app didn't open. That's the same symptom as when not initializing a rich-edit control. I'm assuming that I use the wrong class name, since its the only thing that doesn't explicitly exist in any documentation I've encountered. All docs that are relevant for RE v2 or v3 don't seem to work with 4.1. Any suggestions?
/=/=/=/=
Deus
/=/=/=/=
|
|
|
|
|
What does LoadLibrary() return? If you remove the control from the .RC file, does the app start? Do you have any non-XP machines to test on? If so, change the library being loaded to whatever is on the other machine (e.g., "RICHEDIT").
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|