|
Setting the style to child does not work. The popup window does not show up at all. The Visible property is already checked.
The code to SetForeground code does not work. I also tried SetFocus(), but that didn't work either. Any other clever ideas?
|
|
|
|
|
hmmm I tested the code before I posted it.
Are you using the correct parent window when creating the dialog window?
|
|
|
|
|
How do i know if i'm using the correct parent window?
When created the "loading..." dialog window, i just inserted a new dialog in the resource editor. And then opened class wizard to generate a new class for the new dialog. And the rest of the code, you pretty much know already.
|
|
|
|
|
You are passing "this" as the parent. I don't know what class you are creating the dialog in.
For example, if it is a CFrameWnd derived then you may need to pass the client window as the
parent.
pLoadingDlg->Create(IDD_LOADING,this);
By the way, as Scott mentioned, child windows do get disabled when you disable the parent.
This doesn't affect the visiblility of any windows. I disabled the main window in my example to
prevent the user from doing anything until the operation completes, which is the Microsoft
recommended method. Of course, you can do what you want with the UI as you need to.
This does work
Here's the dialog resource I tested with:
IDD_STATUS DIALOGEX 0, 0, 186, 25<br />
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE<br />
EXSTYLE WS_EX_STATICEDGE<br />
FONT 8, "MS Shell Dlg", 400, 0, 0x1<br />
BEGIN<br />
CTEXT "Test Status",IDC_STATIC,15,7,156,12<br />
END
|
|
|
|
|
this is what i have:
pLoadingDlg->Create(IDD_LOADING,this);
IDD_LOADING is configured as Style: child, Border: dialog frame, title bar, visible, tool window.
Is this correct? The Loading dialog still doesn't show up. But the main window is disabled as expected. I can't click anything during the loading time.
|
|
|
|
|
acerunner316 wrote: IDD_LOADING is configured as Style: child, Border: dialog frame, title bar, visible, tool window.
OK for reference, I tested with the same except no title bar and no toolwindow.
What I'm wondering is in this line
pLoadingDlg->Create(IDD_LOADING,this);
What class "this" points to? Where are you calling this from and what class is the window
derived from?
|
|
|
|
|
this is called in a function belonging to the main dialog's class.
|
|
|
|
|
acerunner316 wrote: this is called in a function belonging to the main dialog's class.
and called from what function?
|
|
|
|
|
Called from yet another function belonging to the same class. I only have one class because everything have been in one dialog box until now.
|
|
|
|
|
acerunner316 wrote: Called from yet another function belonging to the same class.
OK, my point is, as long as you're not creating it in the class' WM_CREATE handler or OnInitDialog()
override it should show.
Are you creating the dialog, doing the processing, and destroying the dialog all in one function?
If so, then you could try this:
...
pLoadingDlg->Create(IDD_LOADING,this);
Invalidate(FALSE);
UpdateWindow();
....do processing
...destroy dialog as usual
|
|
|
|
|
Yes i am creating, processing and destroying all in one function. But on different calls of the function. Therefore, the pointer to CLoading has to be static.
I've tried your new node, it works! But the dialog box is created in the upper left corner of the main dialog box. How can I position it so that it pops up in the center like with the popup and overlap styles?
|
|
|
|
|
acerunner316 wrote: How can I position it so that it pops up in the center like with the popup and overlap styles?
Center of the main dialog?
You could set the Center style to TRUE or move the dialog yourself:
pLoadingDlg->Create(IDD_LOADING,this);
CRect MainDialogRect, LoadDialogRect;
GetClientRect(&MainDialogRect);
pLoadingDlg->GetWindowRect(&LoadDialogRect);
pLoadingDlg->MoveWindow((MainDialogRect.Width() - LoadDialogRect.Width()) / 2,
(MainDialogRect.Height() - LoadDialogRect.Height()) / 2,
LoadDialogRect.Width(), LoadDialogRect.Height());
*EDIT* Fixed the MoveWindow call heh :laugh:
-- modified at 21:55 Monday 27th November, 2006
|
|
|
|
|
The center style seems to center the child dialog relative to the screen and not to the main window.
The code you provided positioned the child dialog where I wanted, except for one problem. The controls in the main dialog appear to overlap the "loading" dialog. I know that controls are considered child windows as well. So how to I make the "loading" dialog on top of the other child dialogs?
|
|
|
|
|
Instead of MoveWindow...
pLoadingDlg->SetWindowPos(wndTop, (MainDialogRect.Width() - LoadDialogRect.Width()) / 2, (MainDialogRect.Height() - LoadDialogRect.Height()) / 2, LoadDialogRect.Width(), LoadDialogRect.Height(), SWP_NOSIZE | SWP_SHOWWINDOW);
Maybe?
|
|
|
|
|
Setting the style to "Child" does not work because, when you disable a window, Windows will automatically disable its child windows as well.
When you used SetFocus, did you do it as follows:
HWND hwndSaveFocus = GetFocus() ;
... (display dialog and delete when done) ...
SetFocus(hwndsaveFocus) ;
Scott
|
|
|
|
|
hwndSaveFocus = GetFocus();
that gives me the error:
error C2440: '=' : cannot convert from 'class CWnd *' to 'struct HWND__ *
|
|
|
|
|
OK, hang on, let me check the API documentaiton....be right back
|
|
|
|
|
OK, my bad...you're evidently using MFC, which provides its own "flavor" of 'GetFocus()'. Try the following:
CWnd* pwndSaveFocus = GetFocus() ;
...
SetFocus(pwndSaveFocus) ;
The difference is that 'GetFocus()' and 'SetFocus()' from the MFC classes operate on an instance of the 'CWnd' class. The code I originally gave you is bare-bones Windows API, and operates on window handles (HWND). The 'CWnd' class in MFC actually encapsulates HWNDs.
Alternatively, you could force the use of the Windows API functions by using the scoping operator to go "outside" the MFC scope to the global scope, as follows:
HWND hwndSaveFocus = ::GetFocus() ;
...
::SetFocus(hwndSaveFocus) ;
The '::' at the beginning of each of the above statements forces the compiler to bypass the MFC functions and map directly to the Windows API.
Hope this gets you a little closer.
Scott
|
|
|
|
|
The MFC SetFocus apparently takes 0 parameters.
Then I tried the global scope with the :: compiled, but still loses focus after destroying the "loading" dialog.
Looks like Marks method is getting me closer. I just need to figure out how to center the child dialog.
Thanks for your help.
|
|
|
|
|
ok, i tried the MFC SetFocus() without any parameters. It works if it comes after destroying the child window. I was using it before destroying the child window before. Only thing is, the window loses focus for a split second after destroying the child window and then regains focus. So it sorta blinks. That's good enough for me right now. So I'll keep it.
|
|
|
|
|
Good!
I'm sorry, I should have been more clear that I thought the LAST thing you would do is reset the focus, making sure it was done after the child window was destroyed. Windows will attempt to set the focus using its own internal (and often misundertood) logic when it shuts down a window. And, or course, God only knows what MFC is doing.
Scott
|
|
|
|
|
Just remembered...
Just in case you didn't know, you should probably override OnCancel() in your modeless dialog
class and do nothing in your implementation (don't call the base class OnCancel()) so the
user can't mess things up with the ESC key
|
|
|
|
|
There is one more way to do it. Make a dialog box with desired message. Create a thread, call DoModal() in this thread to display that dialog box. When u need to kill dialog, kill the thread. How's that??
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
what do this two programs do if anyone can write the commens next to them tnx again
CODE #1
#include <iostream>
using namespace std;
void branje(double *polje, int velikost);
void zamenjava(double *polje, int velikost);
void pomikvdesno(double *polje, int velikost);
void sort(double *polje, int velikost);
void izpisi(double *polje, int velikost);
int main()
{
int velikost = 10;
double polje[velikost];
branje(&polje[0],velikost);
izpisi(&polje[0],velikost);
sort(&polje[0],velikost);
izpisi(&polje[0],velikost);
zamenjava(&polje[0],velikost);
izpisi(&polje[0],velikost);
pomikvdesno(&polje[0],velikost);
izpisi(&polje[0],velikost);
return 0;
}
void izpisi(double *polje, int velikost)
{
static int a=1;
cout<<"Klic st:"<< a <<endl;
for(int="" i="0;" i<velikost;="" i++)
="" {
="" cout<<"stevilo="" je:="" "<<polje[i]<<endl;
="" }
="" a++;
}
void="" branje(double="" *polje,="" int="" velikost)
{
="" cout<<"vpisi="" stevila."<<endl;
="" stevilo:="" ";
="" cin="">>polje[i];
}
}
void zamenjava(double *polje, int velikost)
{
for(int i=0; i<velikost; i++)
="" {
="" if(i="" %="" 2="=" 0)
="" !="velikost-1)
" double="" z;
=""
="" z="polje[i];
" polje[i]="polje[i+1];
" polje[i+1]="z;
" }
="" }
}
void="" zamenjaj(double="" &a,="" &b)
{
="" a="b;
" b="z;
}
void" pomikvdesno(double="" *polje,="" int="" velikost)
{
="" for(int="" i="velikost-2;" i--)
="" polje[0]="z;
}
void" sort(double="" j="0;" j<velikost="" -1;="" j++)
="" i<velikost-1;="" if(polje[i]="" <="" polje[i+1])
="" zamenjaj(polje[i],polje[i+1]);
="" }
}
code="" #2
#include="" <iostream="">
#include <stdio.h>
using namespace std;
struct NIZ
{
char niz[100];
int length;
};
void branje(NIZ *nizi);
void uredi(NIZ *nizi);
void izpis(NIZ *nizi);
int main()
{
NIZ nizi[6];
branje(nizi);
uredi(nizi);
izpis(nizi);
return 0;
}
void branje(NIZ nizi[])
{
for(int i=0; i<6 ; i++)
{
cout<<"Vpisi besedo: ";
cin>>nizi[i].niz;
nizi[i].length=strlen(nizi[i].niz);
}
}
void izpis(NIZ nizi[])
{
for(int i=0; i<6; i++)
{
cout<<nizi[i].niz<<endl;
}
}
void="" zamenjaj(niz="" &niz1,="" niz="" &niz2)
{
="" niz3;
=""
="" niz3="niz1;
" niz1="niz2;
" niz2="niz3;
}
void" uredi(niz="" nizi[])
{
="" for(int="" j="0" ;="" <="" 5="" j++)
="" {
="" i="0;" i<5;="" i++)
="" if(nizi[i].length="" nizi[i+1].length)
="" zamenjaj(nizi[i],nizi[i+1]);
="" }
="" }
}
=""
<div="" class="ForumSig">I'm The Stig
|
|
|
|
|
do the function and variable names have any real meaning in a language other than english ?
except for sort I have absolutly no clue.
|
|
|
|