|
Thanks for your answer!
If using a FILE pointer as a DLL function parameter is not a good programming style, what type of file object should I use instead? I don't use the MFC in my either my main program, or my DLL.
The run time library in my DLL is set to "Multithreaded", but the one in my main program is "Single-threaded". If i set both of them to "Multithreaded", not all the data I write to the FILE from the DLL gets written!
Erik
|
|
|
|
|
see Q190799 "PRB: Potential Errors Passing CRT Objects Across DLL Boundaries" in the MSDN
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
HI ALL
======
My Code goes a little bit like this:
func1() { func2(); }
func2() { func3(); }
func3() { func4(); }
func5() { func6(); }
func6() { goto THREAD_END; }
void thread_main_func()
{
...
...
...
THREAD_END:
...
...
}
Do I need and how to clear the call stack ?
BTW: come to #CodeProject on DalNet (mIRC)
|
|
|
|
|
What you need to do is realise that if you're using goto there is always a better, less satanic way. Using try/catch/throw works better because unlike goto, it's still clear that all your code is headed in the same direction.
Stroustrup is not clear on the question, but I looked up goto in the index and got page 357. which does not mention goto and is about exceptions. It seems to imply try/throw.catch is a better solution stack-wise, but is not clear cut. So I'd not hang my hat on that statement.
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.
|
|
|
|
|
Hi
I think this question has been asked a hundret times already, but I hope someone wanst to help me anyway
I want to show a new dialog, but not with DoModal, the dialog needs to be non-modal.
how can I do this?
I'm using MFC and a dialog-based app
thanks in advance
|
|
|
|
|
For a child of the main dialog, you'll need code similar to this
m_MyModelessDialog.Create(IDD_DIALOGRESOURCE, this);
m_MyModelessDialog.ShowWindow(SW_SHOW);
|
|
|
|
|
I already have this code
CWndTest dlg;
dlg.Create(IDD_MYDIALOG,this);
dlg.ShowWindow(SW_SHOW);
but the windows does not appear
|
|
|
|
|
Don't have dlg defined as a local variable: that causes the dialog to be destroyed as soon as you exit from the function where you defined it; instead, create it on the heap with CWndTest *pDlg=new CWndTest() and make the dialog delete itself on WM_POSTNCDESTROY . See the documentation of your compiler on modeless dialogs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
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)
|
|
|
|