|
QuickDeveloper wrote: Any links or suggestions would do fine.....
SMTP
MAPI
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
|
I need to implement a worker thread in an dialog based MFC. the thread callback function (controlling function that i want to use must be a member of the dialg class itlself but the only functions that the AfxBeginThread function is accepting is the function identifier of a global function of type
AfxBeginThread(MyFunc,....);
//the above statement is to be used in a member funciton(button click event) of a dialog based //MFC.exe
UINT MyFunc(LPVOID lpParam);
How can i use AfxBeginThread if MyFunc also needs to be part of the MFC dialog Class.
Any help in this matter would be great.
If any sample code can be given that would be wonderful.
Sharath
|
|
|
|
|
First declare a funtion in your class
static UINT MyFunc(LPVOID pParam);
now onButtonClick()
<br />
OnButtonClick()<br />
{<br />
CWinThread* pThread = AfxBeginThread( MyFunc, this,<br />
THREAD_PRIORITY_NORMAL,<br />
0, CREATE_SUSPEND, NULL);<br />
<br />
if( pThread != NULL ){<br />
pThread->ResumeTrhead();<br />
}<br />
}<br />
<br />
UINT classname::MyFunc(LPVOID pParam)<br />
{<br />
classname* obj;<br />
obj = (classname*)pParam;<br />
...<br />
}<br />
Regards
Anil
-- modified at 7:22 Friday 2nd June, 2006
|
|
|
|
|
Thanks a lot it worked...too good i have saved a lot of time thanks to your reply...
|
|
|
|
|
When using worker threads keep this in mind. Don't directly manipulate any window / control that your thread did not create! If you must update a window / control, post a message by using PostMessage to the main thread.
Please read Joseph Newcomer's essay on worker threads here: Using Worker Threads[^].
Kelly Herald
Software Developer
MPC
|
|
|
|
|
In addition to the _anil_'s message, after you obtained a pointer to your dialog in static MyFunc function, you can simply call the dialog's member function you need, for instance:
<br />
UINT classname::MyFunc(LPVOID pParam)<br />
{<br />
classname * const obj;<br />
obj = (classname*)pParam;<br />
obj->DoWork();
return 0;<br />
}
It is probably preferable to declare this function as a static member function, inside your class. In this way, you are able to call DoWork even if it is private.
|
|
|
|
|
Hi,
I have a bitmap which contains a image , i want to change the background color of the Bitmap during runtime..How to get current background color of the bit and how to set new background color to the bitmap.
Thanks in before
James
-- modified at 7:15 Friday 2nd June, 2006
|
|
|
|
|
you can use CImage m;
m.SetPixelRGB
whitesky
|
|
|
|
|
can be more clear please.i did not get you.
|
|
|
|
|
you can use GetPixel(x,y) in the loop like this
R=GetRValue(Image.GetPixel(10,10));
m.SetPixelRGB(10,10,R,120,120);
of course this way isnt good because you need to two loop for x and y and if your picture is 1024x768 its not good.
----------
Another way you can draw your bitmap on the dc and use from graphic functions (for example Graphics)
----------
you can codeproject examples that are helpful
whitesky
|
|
|
|
|
WhiteSky wrote: Another way you can draw your bitmap on the dc
Could you please tell me how to draw the Bitmap on DC?
thanx for the reply anyway...
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
|
|
|
|
|
<br />
HDC hdc=CreateCompatibleDC(::GetDC(this->m_hWnd));<br />
HBITMAP hbit=CreateCompatibleBitmap(GetDC()->m_hDC,800,600);<br />
hbit=(HBITMAP)SelectObject(hdc,hbit);<br />
hbit=(HBITMAP)LoadImage(AfxGetInstanceHandle(),"d:\\error.bmp",IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);<br />
<br />
SelectObject(hdc,hbit);<br />
BitBlt(GetDC()->m_hDC,0,0,800,600,hdc,0,0,SRCCOPY);<br />
whitesky
|
|
|
|
|
See i go bit by bit..how do i know the current background color of the Bitmap.I do i know ,what ever color i got from Getpixel is the current color of the Bitmap..and last but not least i am using Vc2005..when i declare CImage image; ERROR :undeclared indentifer CImage..?
|
|
|
|
|
include atlimage
whitesky
|
|
|
|
|
Hello,
Can anybody help me how to distinguish 2 USB audio devices? I have one PCI2USB card (4 ports) and have 4 USB composite (HID + Audio) devices, which can be use which Skype. Anytime I reboot my PC the device name changed, sometimes it is "USB Audio Device", sometimes it is "USB Audio Device 2", sometimes it is "USB Audio Device 3", and sometimes it is "USB Audio Device 4". Anybody know how Windows assign the USB device name? Any naming convention? And finally, how can I get the VendorID/ProductID from the device name? (For example, i want to know if "USB Audio Device 4" is mapped to which vendorID/ProductID?
Thank you in advanced
Best regards,
Dong
|
|
|
|
|
Hi
I hope that you might have known the GUID of your device.
Then you can search for the GUID in registry
[HKYE_LOCAL_MACHINE\SYSTEM\currentcontrolset\control\class]
under this key you will find your GUID key
under your GUID key thir will be one
"MatchingDeviceId" key which stores VID and PID.
Regards
Anil
-- modified at 7:39 Friday 2nd June, 2006
|
|
|
|
|
Anil,
Thanks for quick reply.
Seem that under HKYE_LOCAL_MACHINE\SYSTEM\currentcontrolset\control\class, all USB audio devices have the same name "USB Audio Device". I could not find "USB Audio Device (2)", "USB Audio Device (3)", and so on. But if I open Sound and Audio Devices Properties Dialog, I could see 4 USB Audio Devices "USB Audio Device", "USB Audio Device (2)", "USB Audio Device (3)", "USB Audio Device (4)". I could recognize my USB device is "USB Audio Device (2)". But next reboot, my device may be named as "USB Audio Device (3). So, my previous setting becomes wrong.
Best regards,
Dong
|
|
|
|
|
Hello again
In Unicode build,how to convert a TCHAR array to array of char -s ?
thanks
|
|
|
|
|
|
I thought there might be the API UnicodeToAscii, but not for C++ / MFC ...
Maxwell Chen
|
|
|
|
|
Maxwell Chen wrote: I thought there might be the API UnicodeToAscii, but not for C++ / MFC ...
There is are classes CW2A , CA2W .
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Nibu thomas wrote: There is are classes CW2A, CA2W.
You forgot to mention that these are ATL macros.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
use WideCharToMultiByte
Amar
|
|
|
|
|
Hi,
My application is running fine , When Active Configuration is Win32Release and Project->Setting are "Use MFC in a Shared DLL"
but it crashes when Active Sonfiguration is same Win32Release but change the Project->Setting to "Use MFC in a Static Library"
it crashes at following code.
m_pListenSock is an object of CSock class which is inherited from CSocket class.
UINTCServerHandler::OnMsgStart(WPARAM wp, LPARAM lp)
{
m_pListenSock = new CSock();
m_pListenSock->Create (200); // It crashes at Create call
m_pListenSock->Listen ();
return 1;
}
Regard
|
|
|
|