|
Thanks a lot!
But where do I need to put the "delete pDlg"?
|
|
|
|
|
I tend to put mine in the PostNCDestroy function and do a
delete this.
Michael
|
|
|
|
|
and what happens to the pointer pDlg?
Will it be deleted with this call?
And how can I override PostNCDestroy?
One newbie, many stupid questions
|
|
|
|
|
Ok, I found out, works perfect THANKS!!!!
One final question:
Can I use AfxGetMainWnd() to get a pointer to the dialog who called the new dialog or what do I need to do?
|
|
|
|
|
Use GetParent().
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Yeah, it does. Because your variable is local, the dialog appears for a split second, the variable goes out of scope, and is destroyed. You need to make the dialog a member variable, you can use a pointer, and check for NULL to see if it's visible or not, or use ::IsWindow, in which case you can make it an instance of the class.
I do this in the constructor of my modeless dialogs
if (Create(pParent, IDD)) ShowWindow(SW_SHOW);
and use pointers, then when I call new on the pointer, the dialog comes up right away.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
>I do this in the constructor of my modeless dialogs
>if (Create(pParent, IDD)) ShowWindow(SW_SHOW);
>and use pointers, then when I call new on the pointer, the dialog comes up right away.
What a neat trick. I'll have to remember that one.
Michael
|
|
|
|
|
That is a great idea, Christian.
- Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
In OnInitDialog()
GetParent()->EnableWindow(TRUE);
|
|
|
|
|
Hi, I was wondering how to change a listview control so that the blue selection is not shown.
Does anyone have an idea?
Thx, Joep
|
|
|
|
|
My guess is that you'd have to ownerdraw the control.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Yeah, that's what I'm afraid for ...
Joep Oude Veldhuis
|
|
|
|
|
Joep,
Check out http://www.codeproject.com/listctrl/lvcustomdraw.asp for list control custom draw stuff, if you haven't already. HTH,
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib
|
|
|
|
|
This seems like a simple question. I want to print multiple pages of text. I am using Stringer's fantastic printing class library. Let's say I want to print 2 pages of text.
The user clicks File/Print and a dialog box comes up. I called:
CPrintPages PrintPages;
PrintPages.DoModal();
The user can click from a bunch of check boxes which pages they want to print. Let's say they check m_page1 and m_page2. I do:
void CFormOptions::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
CPage* pPage = new CPage(pInfo->m_rectDraw,pDC);
if (PrintPages.m_page1)
{
void PrintPage1(CPage* pPage);
PrintPage1(pPage);
}
if (PrintPages.m_page2)
{
void PrintPage2(CPage* pPage);
PrintPage2(pPage);
}
...
But it print two (2) pages, with both pages on top of each other. How can I programmatically make it print page 1 and then print page 2? I tried
pInfo->m_curPage ++;
and other things, but nothing I try works. Please, please, any response any one can give me will be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
Hi Danielle,
Printing multiple pages is basically using a loop like this:
CDC dc; // Correctly initialized of course ...
CPrintInfo info; // Correctly initialized of course ...
OnBeginPrinting(&dc, &info);
if (info.m_bContinuePrinting)
{
for (UINT page = info.GetFromPage();
page <= info.GetToPage() && bPrintingOK;
page++)
{
dc.StartPage();
info.m_nCurPage = page;
OnPrint(&dc, &info);
bPrintingOK = (dc.EndPage() > 0);
}
}
OnEndPrinting(&dc, &info);
if (bPrintingOK) dc.EndDoc(); else dc.AbortDoc();
HTH,
Joep
|
|
|
|
|
Howdy,
Is it possible to make a dialog type application stay the same size so if a user changes their desktop settings to "Large Fonts" the dialog would still remain the same size.
I have a dialog type app that uses a bmp for the background/dialog.. everything is cool except for if I change my desktop settings to use large fonts.. then the bitmap stays the same size and my dialog gets much larger causing the app to look terrible.
Any ideas?
Rob
|
|
|
|
|
Well, just resize it in OnInitDialog(), but if there are some controls on it you would need to adjust them too.
You can use GetBitmap() to get the bitmap's size, then MoveWindow() or SetWindowPos() to adjust the dialog's size.
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Thanks Paolo for the info!
I used Set WindowPos() and was able to define the dialog size.. but the controls are still getting enlarged.. do you know the functions that I could use to pre-define the size of the controls or at least keep the size of the controls consistant?
Thanks for you help man!
Rob
|
|
|
|
|
hello
i have this com function (using ATL):
STDMETHODIMP Cmanager::iniGetString(BSTR sSectionName, BSTR sKeyName, BSTR sFileName, BSTR *sRetVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
char sTemp[MAX_PATH];
memset(sTemp, '\0', MAX_PATH);
GetPrivateProfileString (_BSTR_t(sSectionName), _BSTR_t (sKeyName), "none", sTemp, MAX_PATH, _BSTR_t(sFileName));
sRetVal = SysAllocString ((OLECHAR *)sTemp);
return S_OK;
}
the sRetVal return nothing.
I have tried some examples from MSDN but it didn't work
how can i return sTemp?
pls help me.
|
|
|
|
|
is there a value in sTemp?
try sRetVal = _bstr_t(sTemp).copy();
|
|
|
|
|
You should change
sRetVal = SysAllocString ((OLECHAR *)sTemp);
to
*sRetVal = SysAllocString ((OLECHAR *)sTemp);
Your code has sRetVal as a BSTR*, so all you need to do is work on the item the pointer is pointing to. You should also make sure sRetVal is non-null to avoid future crashes & stuff.
Oh, and an OLECHAR is commonly a wide character - you really should convert it instead of typecasting it from a char. Look into a few ATL helpers in "atlconv.h" such as USES_CONVERSION, A2OLE, OLE2T, ect... as well as CComBSTR, they will make your life easier.
|
|
|
|
|
use
*sRetVal = _bstr_t(sTemp);
|
|
|
|
|
I writting a project using MFC and
I need to connect to a (SQL server) but
I don't know how to do it in VC++
so I need to know the object I need and
how to use them.
one Byte can hold some information but not all
MR.Byte
|
|
|
|
|
there are many ways for database conectivity in VC++ , eg ADO, DAO, etc.
ADO is a COM based solution and is more efficient than other technique. ...U have to create a DSN name for this bu using ODBC.....Go to control Panel and Find "Data Sources (ODBC)" , it would help u in creating DSN Name...
Now in MSDN Help find "ADO" the microsoft gang has already provided the sample code for this....;P
|
|
|
|
|