|
Did you call AfxEnableControlContainer() ?
As my daughter would say, "... Whatever!"
|
|
|
|
|
Yes, I called that in the module's InitInstance. Here is the code that throws the assertion in the test container:
<br />
BOOL CWnd::Attach(HWND hWndNew)<br />
{<br />
ASSERT(m_hWnd == NULL);
ASSERT(FromHandlePermanent(hWndNew) == NULL);<br />
<br />
if (hWndNew == NULL)<br />
return FALSE;<br />
<br />
CHandleMap* pMap = afxMapHWND(TRUE);
ASSERT(pMap != NULL);<br />
<br />
pMap->SetPermanent(m_hWnd = hWndNew, this);<br />
<br />
#ifndef _AFX_NO_OCC_SUPPORT<br />
AttachControlSite(pMap);<br />
#endif<br />
<br />
return TRUE;<br />
}<br />
I am not sure how it already has a Permanent handle since I just created the object on the stack. Any thoughts?
Thanks again
Zac
"If I create everything new, why would I want to delete anything?"
|
|
|
|
|
Hello,
What's the most expedient way to simply paint a formatted text paragraph (CString) on to a CView inherited window? I'm running in to a morass of non-wrapping text positioning issues... I just want a self wrapping rectangle or, perhaps a text painter that recognizes the \n in the string.
Thanks!
JennyP
|
|
|
|
|
Take a look at DrawText(), especially the DT_CALCRECT and DT_WORDBREAK flags
HTH
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
EXACTLY WHAT I WANTED! Thanks!
JennyP
|
|
|
|
|
Is there anyway to change the Save button text of the SaveAs dialog of the CFileDialog class to be something else?
Thanks in advance,
Bob
|
|
|
|
|
derive a class from CFileDialog. override OnInitDialog. then, do this:
GetParent()->GetDlgItem(IDOK)->SetWindowText("My new label");
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
Chris,
Thanks for your response. I tried as you suggested, but it crashes. If I do a
<br />
CFileDialog dlg(FALSE, "*.imp", NULL, NULL, szFilter);<br />
CWnd *wnd = dlg.GetDlgItem(IDOK);<br />
it crashes on the dlg.GetDlgItem call. dlg.hWnd = 0.
Perhaps I'm doing this in the wrong place?
Thanks,
Bob
|
|
|
|
|
moobob wrote:
Perhaps I'm doing this in the wrong place?
yup
1. derive a class from CFileDialog (you have to make a new class, not just instantiate a CFileDialog). ClassWizard can help with this.
2. override OnIntiDialog in that derived class (not in the class that uses the new CFileDialog)
3. put that line of code in the derived class's OnInitDialog
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
|
ur reply to the poster is very interesting.
if GetParent() gets the dialog, what does m_hWnd of the new class stand for?
thx
includeh10
|
|
|
|
|
i don't know. that's just code i've always used without even looking at it. it works fine.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
Hello,
I have a research program that runs in an endless loop. However, during this time, I would like the user to be able to stop the loop with, say, a press of a toolbar button (currently, the loop runs but doesn't respond to any other UI interaction). I saw material on 'threads' but it looked like that was specific to NT (I'm on ME).
How do I do this and where should I go for more information?
Thanks!
JennyP
|
|
|
|
|
"threads" is the right answer, and you can use them on any version of Windows.
http://www.codeproject.com/threads/[^]
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
Chris is right.
But you can also use poor man's threading by pumping the message queue, if your endless loop can be broken up into smaller tasks that are repeatedly executed. Here's how to pump the message queue.
while (moreWorkToDo()) {
doSomeWork();
pumpMessageQueue();
if (cancelled()) {
break;
}
}
void pumpMessageQueue()
{
MSG msg;
while (::PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)) {
AfxGetThread()->PumpMessage();
}
}
Regardless of which method you select, remember to ensure that the user is prevented from executing invalid GUI operations (eg: exiting the app) during processing. Usually, the only operations permitted during processing are (1) updating progress and (2) checking if the user chose to interrupt the process.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Since my program is really all about this loop, this solution works perfectly!! Thanks!
JennyP
|
|
|
|
|
Considering Ravi suggestion, you may also disable the parent window of your progress dialog (just reenable it when you are done) if you want to prevent user to close it or anything else.
As my daughter would say, "... Whatever!"
|
|
|
|
|
Actually that's only necessary if the progress dialog is modeless.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Yes, of course!
As my daughter would say, "... Whatever!"
|
|
|
|
|
May be somebody know program, which autocomplete source
for exmaple
for() ctrl+f3(for example) -> for(;;)
{
}
if ctrl+f3(for example) -> if ()
{
}
else
{
}
or how make VC.NET for this;
Delphi it may this
|
|
|
|
|
I need to store, in the system registry,
the setting parameters of my application.
If I use the SetRegistryKey, my parameters
are stored in a specific folder placed in
HKEY_CURRENT_USER -> Software.
How can I store my parameters in
HKEY_LOCAL_MACHINE -> SOFTWARE in order to
be available for all users ???
Thanks a lot
|
|
|
|
|
You'll have to go beyond MFC support for registry. Use RegOpenKeyEx with HKEY_LOCAL_MACHINE as 1st argument, then RegsetValueEx and RegCloseKey.
There should be some classes wrapping Win32 API right here on CodeProject.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
can an exe file write data to itself while running?
i mean, sometimes, an exe file writes data to register or file for many reasons (setting, recording etc.), but i feel in case it is neccessary to write data to itself (i.e. if copy the exe file, setting is copied also because the setting is inside the exe file).
do u think it is possible?
thx
includeh10
|
|
|
|
|
Yes. Study the PE file format for Win32 to make sure you write you data in an acceptable place. That’s the format EXEs are stored in.
Jeremy Falcon
Imputek
<nobr>"Life is too precious - don't waste it." - Norm Almond
|
|
|
|
|
... but he's going to write to .exe while .exe is running. This means PE file is mapped to memory, probably in read-only mode.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|