|
ashish dogra wrote: CMy dlg;
dlg.Create(IDD_DIALOG1);
dlg.ShowWindow(1);
Whats problem with this code
whitesky
|
|
|
|
|
sir
the problem is that when i run application the modeless dialog box open a screen after clicking on ok button of fiest dialog box
but when i cancel the modeless dialog and again click on ok button of first dialog box then it will give an assertion error and does not create modeless dialog box again
plz sovle this one
Ashish Dogra
MCA
Noida
|
|
|
|
|
Can you show how to use and you show your code that has error
whitesky
|
|
|
|
|
void CGd1Dlg::OnOK()
{
CMy dlg;
dlg.Create(IDD_DIALOG1);
dlg.ShowWindow(1);
}
Ashish Dogra
MCA
Noida
|
|
|
|
|
can you show in
CMy::CtetDlg(CWnd* pParent )<br />
: CDialog(CtetDlg::IDD, pParent)
and one suggestion use this function instead your functions and answer to me it work or doesnt work
CMy::CtetDlg(CWnd* pParent )<br />
: CDialog(CtetDlg::IDD, pParent)<br />
BOOL o= Create(IDD,pParent);
-----------
<br />
void CGd1Dlg::OnOK() <br />
{<br />
CMy *dlg;<br />
dlg=new CMy(this);<br />
<br />
dlg->ShowWindow(1);<br />
}<br />
whitesky
|
|
|
|
|
thanks sir it works
thanks a lot ......................HAVE A NICE DAY
Ashish Dogra
MCA
Noida
|
|
|
|
|
After exiting DoModal, the attached window of CDialog object is destroyed and detached, so there is no problem to call DoModal again.
For a modeless dialog (made with CDialog::Create), unless the CDialog object goes out-of scope or DestroyWindow was called, the window is not destroyed, not even the user pushes OK/Cancel/close button.
So you have to test if the dialog was created before call CDialog::Create.
If yes, then simply show it:
void CFoo::ShowModelessDialog(CDialog& dlg, UINT nResID)
{
if(!::IsWindow(dlg.m_hWnd))
{
dlg.Create(nResID, this);
}
dlg.ShowWindow(SW_SHOW);
}
ShowDialog(m_dlg, IDD_DIALOG1);
ShowDialog(m_dlg, IDD_DIALOG1);
NOTE: You can test m_hWnd against NULL instead of calling ::IsWindow, as well.
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
In you use this code
void OnSomeFunction()
{
CMy dlg;
dlg.Create(IDD_DIALOG1);
dlg.ShowWindow(1);
}
this is not safe, because the dlg object is created in Stack and it will get destroyed
as soon as the function is out of scope.
Create ModeLess Dialogs in Heap or Make Sure that the Object is not out of scope by making is
static or Global/Top Clsss Variale Like.
One Way of Doing It is:
void OnSomeFunction()
{
static CMy * Dlg =NULL;
if (!m_Dlg)
{
Dlg= new CMy();
Dlg->Create(IDD_DIALOG1);
}
dlg.ShowWindow(1);
}
|
|
|
|
|
Hey, hey, dear Indian Idol!
To be clear.
I didn't suggest to declare a CDialog object locally in a function. Did you see that in may example?
If you pay a little bit more attention, can observe that I prefixed with m_ which suggest that m_dlg is a member of class CFoo.
And your static CMy *Dlg locally declared in OnSomeFunction() smells a C.
And by the way... where you think it's possible to delete *Dlg in order to get rid of memory leaks?
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
i want to clear the dats which is present in file.
how should i can do this.
because if i use Remove() method file is deleted.
so want to clear the data not to delete the file.
sree.
|
|
|
|
|
use CFile::SetLength()
SetLength( 0 ); // Will clear all the datas
nave
|
|
|
|
|
Just open the file with CFile::modeCreate flag.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
HI All
Working on a wizard type dilaog application and taken the idea of creating wizard from the below link
http://www.codeproject.com/dialog/wizard2000.asp
Here having one problem:
what I am doing is that Suppose right now on property page number 3 and performing some operaion, after finishing operation want to jump on the next page (number 4) automatically, without clicking on the Next Button.
For this using SetActivePage(int i) function. but this function throws exception.
One more thing that when I jump from Page 3 to Page 2 it jumps successfully, problem is with the pages ahead.
So Please tell me that how to jump over the next page in the wizard automatically
Please help.
Thanks
|
|
|
|
|
You get exception because dialog for the 'next' page has not been created yet.
I usually send a 'faked' next button press to the parent of wizard pages and it 'thinks' the user has pressed next button. That seems to always work out well.
I've seen better runs in my shorts! - Patches O'Houlihan
|
|
|
|
|
Hi,I have taken FormView,in which i have created ListControl,The client area, "rect" of the FormView is taken is taken as i/p for ListControl Creation.I have handled WM_CONTEXTMENU in the formview,in the ContextMenu,there are two items one is "Print" another is "PntView"..ON_COMMAND of both ID_PRINT and ID_PRIVIEW i have handled in formview.in the respective functions i have called CFormView::OnFilePrint,CFormView::OnFilePrintPriview,i have overriden "Onprepareprinting" and "OnPrint".When i click print in the context menu , it is printing,when i click priview in the context preview is coming,but in the preview when i print button,it is not printing , what could be the reason...
Thanks in before
James
-- modified at 0:40 Thursday 29th June, 2006
|
|
|
|
|
When you click in this button your code is running or no
whitesky
|
|
|
|
|
No it is not called.it is called when i click print and printpreview in context menu....
-- modified at 4:35 Thursday 29th June, 2006
|
|
|
|
|
well i guess your problem is event button do you check event for your button
whitesky
|
|
|
|
|
i am on mfc dialog based. how to open a new dialog box on clicking the button .
prashant jain
|
|
|
|
|
CClassname dlg;
dlg.DoModa();
Ashish Dogra
MCA
Noida
|
|
|
|
|
//the CNewDlg is new dialog box class
//add these code to button proc
//(my english is very poor)
//ex:
<br />
void COldDlg::OnButton1()<br />
{<br />
CNewDlg dlg;<br />
dlg.DoModal();<br />
}<br />
|
|
|
|
|
m_Dialog.DoModal();
or
<br />
m_Dialog.Create(IDD_YOURDIALOG);<br />
m_Dialog.ShowWindow(1);<br />
whitesky
|
|
|
|
|
hi,
i want to change email address in outlook2003 when the user submit the message. i use IExchExtMessageEvents::OnCheckNames(IExchExtCallback *lpExchangeCallback) to change email-address. my code is following.
And i see the email-address have changed on debugging. but at last, outlook2003 still send message using the old email-address, and abandon my changed email-adddress, why???
who will give me some suggestions?? or is there any other ways to changed email address??
thanks a lot.
my email is: how_fly@yahoo.com
//in VC6, winxp2, outlook2003
class mymail : public IExchExt, public IExchExtMessageEvents
{...};
STDMETHODIMP mymail::OnCheckNames(IExchExtCallback *lpExchangeCallback)
{
HRESULT hRet = S_OK;
LPMESSAGE lpMessage = NULL;
LPMDB lpMdb = NULL;
LPADRLIST pRecipentRows = NULL;
lpExchangeCallback->GetRecipients(&pRecipentRows);
if( pRecipentRows->cEntries == 0 )
return S_FALSE;
for(unsigned long n = 0; n < pRecipentRows->cEntries; n++ )
{
for(unsigned long i = 0; i < pRecipentRows->aEntries[n].cValues ; i++)
{
ULONG ulTag = pRecipentRows->aEntries[n].rgPropVals[i].ulPropTag;
if( PR_EMAIL_ADDRESS == ulTag || PR_DISPLAY_NAME == ulTag)
{
// i get the current email address correctly, such as "old_email@1.com"
LPSTR pNow = pRecipentRows->aEntries[n].rgPropVals[i].Value.lpszA;
// i want to change email address to "xxx@xxx.com"
char* p = "xxx@xxx.com";
char* pNewContact = NULL;
MAPIAllocateBuffer(strlen(p)+1, (LPVOID FAR *)&pNewContact);
strcpy((char*)pNewContact, (const char*)p);
pRecipentRows->aEntries[n].rgPropVals[i].Value.lpszA = pNewContact;
}
}
}
hRet = lpExchangeCallback->SetRecipients(pRecipentRows); //is S_OK
return S_FALSE;
}
-- modified at 2:53 Thursday 29th June, 2006
|
|
|
|
|
Maybe instead of
strcpy((char*)p, (const char*)pNewContact);
you should have
strcpy(pNewContact, p);
Hope it helps.
|
|
|
|
|
oh, sorry,i type the code wrong. i have corrected it.
but it is still not work well.
thanks any way.
|
|
|
|