|
Thanks Anthony,
That did it.
|
|
|
|
|
Hi,
I am trying to write a control derived from CComboBox. I want to make sure that the owner draw flag is set even if it has not been done in the resources.
So in PreSubclassWindow, I do this
<br />
void CMyComboBox::PreSubclassWindow() <br />
{<br />
CComboBox::PreSubclassWindow();<br />
<br />
UINT nStyle = GetStyle();<br />
if ( !(nStyle & CBS_OWNERDRAWVARIABLE) || !(nStyle & CBS_HASSTRINGS) )<br />
SetWindowLong(m_hWnd,GWL_STYLE,nStyle | CBS_OWNERDRAWVARIABLE| CBS_HASSTRINGS);<br />
}<br />
This does not work... DrawItem does not get called. Any idea?
Thanks in advance
|
|
|
|
|
I believe that you have to specify that the control is owner-drawn before it is created. Subclassing a control in this manner, the window is created before before PreSublassWindow is called, so your modification of the window style has no effect.
|
|
|
|
|
Thanks for your reply.
Any idea of what I should override to be able to do this?
|
|
|
|
|
Yeah - check the property sheet checkbox.
There are a few approaches. I think the slickest (especially in VS.NET 2003, as opposed to VS6) is the use of the 'Custom Control' toolbox item.
Check out the MFC sample 'CTRLTEST', in particular the file (and documentation regarding) paredit2.cpp and .h - the parsed edit control w/ an 'Exported' class for use inthe dialog editor. It'll take a while to understand how it works, but it's a neat trick to know.
|
|
|
|
|
Does anybody know how to fill the fields of IE's web page
from within VB or C++ ? What if the page is secure? Of
course, there is no problem to fill all the fields by
hand. The question is how to do it automatically, by
running .exe or .dll.
|
|
|
|
|
It is depends on wheither your form it to be submited by POST , by COOKIES or by QUERYSTRING.
If your web page form is using querystring, you just ammend the URL
like
http://www.codeproject.com/script/comments/user_reply.asp?forumid=myIDblahlblah
Check out some ASP/JSP/PHP/Perl tutorial to understand the concept
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
how to communciate with a serial or com or usb port using mfc
|
|
|
|
|
You don't
You use ::CreateFile and give it a name such as "COM3:" If you want to talk to a USB port you have to make sure your USB device offeres a device in the serial port (or modem) class in its ACL to get a COM port assigned to it
You probably can use CFile to do the same, but ive never tried.
There are numerious serial port wrapper classes on CP and www.codeguru.com
|
|
|
|
|
how to display data from an oracle table into combo box and edit control.
|
|
|
|
|
i have a dialog box where i am having a combo-box control and two edit controls.i want to insert the value of the combo box which i select and also of the two d\edit controls into a table in oracle database when i click the ok button.i want to use the CDatabase.ExecuteSqlQuery command.how should i write the insert statement.
|
|
|
|
|
m_combo.GetWindowText(strComboText);
m_edit1.GetWindowText(strEdit1Text);
m_edit2.GetWindowText(strEdit2Text);
strSQLQuery.Format("INSERT INTO <table> (column list) VALUES ('%s', '%s', '%s')",
strComboText, strEdit1Text, strEdit2Text);
CDatabast.ExecuteSqlQuery(strSQLQuery);
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
How can I draw a line with a style that has dots smaller and and more closely placed than PS_DOT style in CPen? I would like to draw like the one drawn by the function DrawFocusRect, but would like to be able to change the color.
Thanks
|
|
|
|
|
I'm intercepting all the alt keys in my CDHtmlDialog derived dialog
application, but I can't seem to intercept the control-N "new browser" key
combination. Unlike CHtmlView, CDHtmlDialog doesn't have an OnNewWindow2
event handler.
I'm using C++ in Visual Studio .Net 2003.
I should know how to do this, but I don't.
Hints or pointers to a faq are very welcome.
Thanks,
Jim Howard
|
|
|
|
|
hi,
i am developing an install/uninstall program, but i have Q about remove items from Start Menu.
following lines can easily add items to Start menu
//=================================================
CString csBuf= "[progman.groups]\r\n"
"groupX=_g0\r\n"
"[groupX]\r\n"
"\"R0\",\"c:\\_temp\\abc.txt\"\r\n"
"\"R1\",\"c:\\_temp\\efg.txt\"\r\n"
"\"c:\\_temp\"\r\n";
const CString csIni="C:\\WINDOWS\\setup.ini";
int fh=_lcreat(csIni,0);
if(fh!=-1)
{
_lwrite(fh,csBuf,csBuf.GetLength());
_lclose(fh);
WinExec("grpconv -o",SW_SHOW);
}
//=========================================
Q:
1. how to delete (uninstall) items from Start menu programmatically (any way)?
2. is code above good for add items to Start menu? what is best or better method?
3. any recommend for install/uninstall (espcially-uninstall) samples (links etc) - samples in msdn look no good.
thanks
includeh10
|
|
|
|
|
|
where is it?
i never use any so far.
includeh10
|
|
|
|
|
|
thanks
i will try soon.
by the way, does it include uninstall package also?
includeh10
|
|
|
|
|
|
Hi there
I want to use some javaScript from VC++ (an XPointer implementation) and everything works fine with execScript on the IHTMLWindow2 interface.
But...
Then I want to receive some Xpointer data from another process. I start a VC++ thread and once it is finished and has received the data it sends the data back to my BHO. I once again use the exact same code from obove that worked before only now the execScript returns the error value -2147418113 which translates to "Catastrophic failure".
Why?
Is it the thread maybe, interrupting the browser when its not ready to run JavaScript. Anyone recognize or know how to solve this?
Kind regards Rene.
|
|
|
|
|
I wonder if anyone can advise me about the following.
I am currently working on an application that uses multiple worker threads to perform concurrent processing.
It requires 50+ workers (although it may require many more in the future), each instantiating an object to perform some processing.
I am using ::WaitForMultipleObjects() to wait for all the threads to terminate.
Now, some threads run very quickly as they do not have that much to do and so they tend to terminate even before the last worker thread has been dispatched.
As a result, the wait fails..
Do I assume correctly, that this occurs because the wait function determines that those threads that are already signalled and therefore have invalid handles are considered an error.
So, how do I contend with the fact that some threads may already be signalled before the wait gets called.
I would like to be able to wait until all the threads have completed before execeution of the main dispatching thread continues whether they are non-signalled or signalled before the wait is called.
Any comments or advice would be greatly appreciated.
James.
|
|
|
|
|
The thread objects are not deleted until all handles are closed. As long as you're keeping your handles open until you need to Wait, you'll be fine. The system keeps the object around so that you can wait on the object, should you need to.
Be aware that a large number of threads will tend to cause context thrashing if they're contending for CPU time. Consider using a thread pool instead. See the QueueUserWorkItem function for using the built-in thread pool on Windows 2000 or later.
|
|
|
|
|
Hi.
Thanks for the reply.
The issue is not one of too many threads competing for a timeslice, as 99% of them are only active for a fraction of their lifetime. Infact they are only active when told to be via event handling.
I have been looking through the archives and found an interesting discussion that I had not seen before concerning DuplicateHandle() or some such that I might be able to use to define a duplicate handle for each thread ensuring that the wait has valid handles to reference even if a child worker has already become signalled before the wait function is requested.
Cheers.
James
|
|
|
|
|
How do you mean the wait "fails"? As in tells you that you've given it an invalid handle? The thread handle should still be valid until it's closed with CloseHandle, and should be deemed "signaled" if they have terminated - providing you tell WaitForMultipleObjects to wait for all objects pased (3rd parameter) it should wait for all the threads to terminate - I have a similar snippit of code that kicks off 64 threads off different life spans and that works.
Could you put up the code that starts and waits for the threads.
Also, are you starting the threads with CreateThread() or _beginthread(ex)?
|
|
|
|