|
That's probably the easiest way in the end. Thanks for all the help Ravi!
|
|
|
|
|
I need to encode a .exe file in order to put its content into some XML's CDATA. Is there any code here on CP handling such task?
rechi
|
|
|
|
|
If you're not searching for any particular encoding mechanism, one of the simplest is to substitute every byte by its representantion in hexadecimal. Doing such a coder/encoder is trivial.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
i have made a help file by using help tool provided by microsoft visual tools.
now i want to include that in my project . please tellme how to include those files in the project,
thanks
looking forward from all the gurus of code
|
|
|
|
|
You'll find an abundance of information here[^].
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I have an OCX that I wrote containing two controls: a serial port enumerator (gives a list of the available serial ports on a system), and a serial port control (does the communications, event firing etc). The enumerator doesn't have any properties (just 1 method that returns a SAFEARRAY of BSTRs with port names). The serial port control has the usual serial port properties (baud rate, parity, handshaking, data bits, stop bits, and which events the user wants notification of). In the InitDialog function of the Serial port's property page, I wanted to use the Enumerator to fill in a combo box with the port names. However, when I try this, it gives an exception and crashes whatever container it is in. Here is how I am trying to create the enumerator control:
<br />
BOOL CSerialPortPropPage::OnInitDialog() <br />
{<br />
COlePropertyPage::OnInitDialog();<br />
CWnd wndEnum;<br />
CRect rc;<br />
<br />
rc.SetRect(0, 0, 0, 0);<br />
if (FALSE == wndEnum.CreateControl(_T("SERIALPORT.SerialEnumeratorCtrl.1"), NULL, 0, rc, this, 5000))<br />
AfxMessageBox("Enumerator Creation failed!");<br />
else<br />
AfxMessageBox("Enumerator Creation Passed!");<br />
<br />
return FALSE;
Is there something I am doing wrong (I've been looking at it way too long . . . everything looks okay to me, but it still isn't working).
If this isn't correct, does anyone have a better way of accomplishing this?
Thanks
Zac Howland
"If I create everything new, why would I want to delete anything?"
|
|
|
|
|
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!"
|
|
|
|