|
The snippets as follows:
CAboutDlg dlg;
dlg.DoModal();
Now,how to pass data to the modal dialog,for example modify the title of the modal dialog.Thx!I am not a genius, but shed more sweat!
|
|
|
|
|
Override OnInitDialog and change any values there. If you need the values to be set before instantiating the dialog then add class members and set their values when you first create the dialog object.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
You could extend the constructor of the dialog
to accept the passed parameter(s) by dialogs member(s).
As Richard said,
all visual things should be apllied at OnInitDialog() ,
as the m_hWnd is already valid,
for example:
if (m_cszPassedTitle.GetLength()) {
SetWindowText(m_cszPassedTitle);
} Check your definition of Irrationality[ ^]
1 - Avicenna
5 - Hubbard
3 - Own definition
|
|
|
|
|
The other alternative to the above suggestions, is that you define your own message, and use that to signal to your
child window that you've got some data for it.
I use the following code to pass an image to a child window.
IDC_COPYIMAGE is the message I defined. (#define IDC_COPYIMAGE 1010) There just needs to be an appropriate handler in the windowproc for the child dialog.
if (myWad.getLumpSize(myItem.iItem) == 4096)
{
flatData = (char*)myWad.loadResource(resNum, &resLen);
pal = (char*) myWad.loadResource(195, &resLen);
darkMap = (char*) myWad.loadResource(1, &resLen);
tmpImg = createImageFromFlat(flatData, pal, darkMap);
delete pal;
delete flatData;
delete darkMap;
SendMessage(imgChildHWND, IDC_COPYIMAGE, 0, (LPARAM)tmpImg);
DeleteObject(tmpImg);
}
|
|
|
|
|
I want to create a modeless dialog as main window. But I got error when calling function CreateDialog:
Unhandled exception at 0x7e424d76 in ModelessTest.exe: 0xC0000005: Access violation writing location 0x00000014.
This is my code:
BOOL CModelessTestApp::InitInstance()
{
CWinApp::InitInstance();
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
CModelessTestDlg dlg;
m_pMainWnd = &dlg;
LPTSTR szAppName = MAKEINTRESOURCE(dlg.IDD);
MSG msg ;
WNDCLASS wndclass ;
memset(&wndclass, 0, sizeof(WNDCLASS));
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = ::DefWindowProc;
wndclass.cbWndExtra = DLGWINDOWEXTRA;
wndclass.hInstance = AfxGetInstanceHandle();
wndclass.hIcon = LoadIcon(IDR_MAINFRAME);
wndclass.hCursor = LoadCursor(IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wndclass.lpszClassName = dlg.IDD_CLASS;
if (!AfxRegisterClass(&wndclass)) {
TRACE("Class Registration Failed\n");
MessageBox (NULL, TEXT ("This program requires Windows NT!"), szAppName, MB_ICONERROR);
return 0 ;
}
HWND hDlg = ::CreateDialog(GetModuleHandle(NULL), szAppName, NULL, NULL);
ShowWindow(hDlg, SW_SHOW);
while (GetMessage(&msg, NULL, 0, 0)) {
if (!IsDialogMessage(hDlg, &msg)) {
TranslateMessage(&msg) ;
DispatchMessage(&msg) ;
}
}
return FALSE;
}
The error is at this line:
HWND hDlg = ::CreateDialog(GetModuleHandle(NULL), szAppName, NULL, NULL);
But If I use the MFC way to create the modeless dialog, there is no error. For example, in above code, these codes:
HWND hDlg = ::CreateDialog(GetModuleHandle(NULL), szAppName, NULL, NULL);
ShowWindow(hDlg, SW_SHOW);
are replaced with:
dlg.Create(dlg.IDD);
dlg.ShowWindow(SW_SHOW);
HWND hDlg = dlg.m_hWnd;
it will manage to create the dialog.
Anyone know what's the cause?
Note: I'm using VC++ 2005
Thx in advance.modified on Saturday, March 6, 2010 5:13 AM
|
|
|
|
|
Your CreateDialog() call is missing some parameters; see here[^] for the description of what is required.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Could you tell what's the missing parameter? I am totally clueless about this. I'm once thinking that I have to specify the DialogProcedure, but I saw the example from other resource (if using pure windows API way) that it doesn't need to specify the third and fourth parameter. Then I tried to provide the DialogProcedure and it still got error.
|
|
|
|
|
rudyono wrote: Could you tell what's the missing parameter?
The link I gave you clearly shows what parameters this function requires.
rudyono wrote: I am totally clueless about this.
I suggest you try something simpler; the code you posted above appears somewhat complicated. I am not sure what it is you are trying to achieve here or why you want to use a modeless dialog instead of a normal main window for your program.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
rudyono wrote: I want to create a modeless dialog as main window.
In what way are they different:
a modal dialog as main window and
a modeless dialog as main window ? Check your definition of Irrationality[ ^]
1 - Avicenna
5 - Hubbard
3 - Own definition
|
|
|
|
|
The distinction between modal and modeless dialogs is important and significant, but in your particular case of the main app window, I have to agree with Eugen Podsypalnikov that it seems to be a moot point.
I notice as well that you have written your own message loop and included it in App::InitInstance, bypassing the one provided as a part of MFC. I see no reason for you to be doing this.
I am puzzled by what you are trying to do here. It seems to me that you are writing an MFC app, but specifically bypassing MFC in it, instead nesting a win32 api application inside of it. This makes me nervous about how the various pieces of code in your app will interact.
Writing an MFC app is fine.
Writing a win32 app is fine.
I don't get what you are doing here. Perhaps you could try and clarify things for at least one of us? Please do not read this signature.
|
|
|
|
|
Here is the story, I want to make an MFC application with a splash screen. The problem is my app is a modal dialog and a modal dialog cannot startup as invisible, so that's why I was looking for modeless dialog as main window way. I was succeeded (to make modeless dialog as main window as said in my first post. It's just a curiousity that I replace the 2 line of MFC code to create a modeless dialog with win32 API code to do same thing, and it failed to create a modeless dialog. So I just want to know why the win32 API code is failed?
Btw, I already know how to solve my initial problem pertaining relationship between modal dialog and splash screen, so I had switched back to modal dialog.
|
|
|
|
|
Hi all,
i want to convert a CString value to DWORD. My problem is i am having hex value in my CString variable for ex.
CString str = 0x002C036D;
now i want to convert this value to DWORD.
How can i do this??????
Thanks in advance...
|
|
|
|
|
you can covert it to char * first,then use atoi.
Good Luck !
|
|
|
|
|
The statement
CString str = 0x002C036D; does not make much sense to me. Maybe you meant to say
CString str = _T("0x002C036D"); A simple function will do the conversion. You probably need to take a look at the function sscanf .
|
|
|
|
|
|
Hi all,
Im trying to write MJPEG frames into AVI container.
AVIStreamWrite function is getting failed.It returns the error code -2147205014.
Im not able to proceed further.
Could any one help me?
Thanks
|
|
|
|
|
|
I want to use the CHtmlEditView in my vc 6.0 project.
so i added the header file 'afxhtml.h' and then added the following line.
CHtmlEditView htmleditview_object;
then i compile the project and its giving the error like
error C2501: 'CHtmlEditView' : missing storage-class or type specifiers.
what should i do?
How do i solve this problem?sunnyram
|
|
|
|
|
ftp and gopher have related finder classes of CFtpFileFind and CGopherFileFind respectively.
but how to find files with http protocol?
is it impossible?
|
|
|
|
|
I might be talking complete rubbish, but I don't think HTTP servers support searching. I've certainly never come across a program that lets you do it, and I've come across plenty of FTP ones.
|
|
|
|
|
The HTTP protocol does not offer this. Perhaps the web server provides a search or directory service you can use.
Cheers, M
PS: If it was another user posting this question, I would not be very surprised about a followup-post describing what you want to achive and we could start a communication to discuss alternatives and find a technical a solution. But since it is includeh10 we will never know. Hope I could help anyway, see you next time.
|
|
|
|
|
Hi all,
i m working on Dialog based application,
here diffreant types of controls placed over the dialog box like,Edit box,static box,button,list elc.
some dialog boxes popup on button clicked.
after some time using of application its becomes so slow,even if i restore it from minimize state its take some time to display the controls of dialog box.
and the memory usage of application increase and increase.
please tell me how can i reduce the memory usage of application,and make it stable wheather its use or long time,
please tell me how can i resolve the problem of slow responding or not responding.
thanks in advance.
|
|
|
|
|
Try Googling "memory leaks". Steve
|
|
|
|
|
As Steve suggested, your application probably doesn't perform well the necessary cleanup, i.e. keeps allocating new objects without calling delete on the 'dead' ones.
Correct handling of dynamic memory is one of the major duties of the C/C++ developer.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Try to analyze debuggers output lines after the applications exit Check your definition of Irrationality[ ^]
1 - Avicenna
5 - Hubbard
3 - Own definition
|
|
|
|