|
yes. Here is my function that send the message from a thread I created:
<br />
typedef struct tagCONNSTATUS {<br />
int nConnID;<br />
CString sThreadID;<br />
CString sConnStatus;<br />
}CONNSTATUS;<br />
CONNSTATUS ConnStatus;<br />
<br />
ConnStatus.nConnID = ConnID;<br />
ConnStatus.sThreadID = thdID;<br />
ConnStatus.sConnStatus = "Connected";<br />
<br />
COPYDATASTRUCT myData;<br />
myData.dwData = 0;<br />
myData.cbData = sizeof(ConnStatus);<br />
myData.lpData = &ConnStatus;<br />
<br />
<br />
if (!SendMessage(myHandle->m_hWnd, WM_COPYDATA, 0, (LPARAM)&myData))<br />
MessageBox(NULL, "Error Posting Connection Message", "Error on PostMessage", MB_OK | MB_ICONEXCLAMATION);<br />
<br />
Here is the function that receives the message in my main application:
<br />
BOOL CLAMsgSwDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)<br />
{<br />
typedef struct tagCONNSTATUS {<br />
int nConnID;<br />
CString sThreadID;<br />
CString sConnStatus;<br />
}CONNSTATUS;<br />
<br />
(DWORD)((CONNSTATUS*)(pCopyDataStruct->lpData))->nConnID;<br />
(LPCSTR)((CONNSTATUS*)(pCopyDataStruct->lpData))->sThreadID;<br />
(LPCSTR)((CONNSTATUS*)(pCopyDataStruct->lpData))->sConnStatus;<br />
<br />
CONNSTATUS ConnStatus;<br />
AfxMessageBox(ConnStatus.sConnStatus);<br />
AfxMessageBox(ConnStatus.sThreadID);<br />
<br />
return 1;<br />
}<br />
<br />
When my message boxes pop up they show nothing.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom Wright wrote:
typedef struct tagCONNSTATUS {
int nConnID;
CString sThreadID;
CString sConnStatus;
}CONNSTATUS;
CONNSTATUS ConnStatus;
AFAIK the problem is with the CString s. They contain pointers to the actual string data, and you can not pass pointers across process boundaries as the pointers will have no meaning to the recieving process.
You have to build your structure in such a way that it does not contain any pointers. For example:
typedef struct tagCONNSTATUS {
int nConnID;
TCHAR sThreadID[128];
TCHAR sConnStatus[128];
} CONNSTATUS;
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Yeah I'm still getting nothing. I've tried it where I'm passing a test string from a CString object and that worked. However I cannot get a structure to pass coreectly. Not sure what I have set wrong.
Thanks for the help anyway. I'll keep plugging a long.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
The concept is not difficult. All it does is copy cbData bytes from the memory at lpData .
If you want to see a working example, take a look at http://www.codeproject.com/tools/imageviewer.asp[^]. The sending code is in the ViewerDll project; ImageView function. The receiving code is in the ViewerApp project; OnCopyData function.
I am willing to provide more help if you need it, just ask.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I figured it out. I needed to do a memcpy on the receving side. Once I did that I was able to receive all the data in my struct.
<br />
typedef struct tagCONNSTATUS {<br />
int nConnID;<br />
TCHAR sThreadID[128];<br />
TCHAR sConnStatus[128];<br />
}CONNSTATUS;<br />
<br />
CONNSTATUS ConnStatus;<br />
memcpy(&ConnStatus, pCopyDataStruct->lpData, sizeof(ConnStatus));<br />
m_lClientConn.SetItemText(ConnStatus.nConnID, 3, ConnStatus.sConnStatus);<br />
Thanks for the help.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
I'm trying to insert a status bar control inside a the activex window in OnCreate. It only appears if i resize the window, also how can i change it from being indented(Pushed In) i would like it closer to what the Mainframe window looks like.
Thanks
|
|
|
|
|
Maybe I'm totally wrong here but wouldn't it be better off to create your status bar in the OnInitdialog()?
I'm confused are you trying to create and activex control that has a MDI window in it, and you want a status bar on the child windows? Or are you creating an activex control with a dialog window in it and are placing it in a MDI app, and you want a status bar in the dailog box / activex control?
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Rather than creating CStatusBar in OnCreate function Better to Create OnPaint Function .. I hope it will work .. becos every time u resize or any changes on window it calls to onpaint function..
|
|
|
|
|
Hello,
I was wondering if there is any other way of setting the text in a static control to bold - except constructing my own font?
Thanks!
|
|
|
|
|
in resource editor, you can change the font of the entire controls in a dialog.
Ninety-eight percent of the thrill comes from knowing that the thing you designed works, and works almost the way you expected it would. If that happens, part of you is in that machine.
|
|
|
|
|
Well,
the problem is that I don't want to change the font for the entire dialog but for that specific static control
Thanks for the help anyway
|
|
|
|
|
Deian wrote:
I was wondering if there is any other way of setting the text in a static control to bold
Bold is a font too, and there is no ready made method to make something change the font, I guess you need to create the font and attach the new font.
Basically its how everything works, except that a default font is attached to it.
-prakash
|
|
|
|
|
Hello guys, I've a little bomb in my hands. I have some code that should create a CDialog and start a downloader thread (wich is inside the CDialog derived class). When the thread finishes, I have to finish the CDialog also, and I'm currently using a pointer to the same CDialog and calling the "EndDialog" function through the pointer. The fact is that, only with WinXP, sometimes this causes a runtime error. I don't know exactly what is causing this, and I know it's not the best way to do that, but I just lack the time to rewrite this now.
Thanx!
|
|
|
|
|
|
Thanks a lot man. A simple "SendMessage" solved the problem, at the end of the thread.
|
|
|
|
|
We had a similar issue in that we needed to minimize, restore, or close the app from another application. So I wrote a DLL that had this section of code that has to this day worked great. I pass the name of the window that I want closed and it does the rest.
<br />
HWND hWnd;<br />
LRESULT lpResult;<br />
<br />
hWnd = FindWindow(NULL, winName);<br />
if (hWnd == NULL)<br />
{<br />
return 0;<br />
}<br />
lpResult = DefWindowProc(hWnd, WM_SYSCOMMAND, SC_CLOSE, NULL);<br />
if (lpResult == NULL) return 0;<br />
<br />
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Passing the window title isn't quite safe as there can be other windows with this name, e.g. other instances of the app.
To be safe against coincidences, it's much better to use HWND.
PS. This is one thing why I respect learning pure API first, then MFC or other interface libraries, and encourage my brother to do so . You know exactly what you do and what is behind the MFC classes.
|
|
|
|
|
That is true AND false
I've been learning pure API since I started programming, and using libs like MFC when I need things up and running fast. The fact is, there is no way to know what is going on with MFC because the documentation LIES, the source code they provide LIES and there are dozens of GOTOs (!!!) inside it! Please guys, raise a hand the ones who use GOTOs (and don't work at Microsoft...).
Yes, I'm a little bit disturbed, but that's the result after working since long date with mfc... (the Microsoft Frustration Classes)
|
|
|
|
|
Ah...am I missing somthing here or do I not see that FindWindow returns an HWND????
If you really wanna make sure you have the right window you would have to know the window handle first and pass that to your app. or enum all the windows and decide from that which one is the right window. Other than that if you had 2 internet explorers up looking at the same website then you would not know which one to choose except by taking a look at the z-order and trying to determine which one has been up longer.
Fortunatly we know the windows title and know that they are unique, so this is why we can do a findwindow and close them the way I suggested.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Has anyone come across this problem? I have a VC6 MFC app that I want to continue developing in VC.NET2003 I can build the project and Intellisense works and all that, but when I want to add a new MFC class using the Class Wizard, It complains that I can only add an MFC class to an MFC project. Any ideas/solutions?
thanks
|
|
|
|
|
Hi,
I have a layered window which I'd like to only display when the user is viewing the desktop.
I've tried setting the parent style to the desktop handle (GetDesktopWindow()) and to set its z-order to SWP_BOTTOM but somehow none of this has the desired effect
I only want to display the window on the desktop, not anywhere else.
Does anyone know of some specific tricks to achieve this?
Cheers,
|
|
|
|
|
hm. u must understand that map is not a simple vector - its a structure with 2 or more values in a carriage. read more on std::map in MSDN.
4apai
There're no impossible tasks. There're tasks that required infinite period of execution time.
|
|
|
|
|
I want to copy the text as well as image bmp to be copied and to another RichEdit Control from one RichEdit Control on button pressed .The text data is going but image is not going.
pls help me
Learner always
|
|
|
|
|
how can i create calculus functions using c++
|
|
|
|
|
simple answer : yes.
There are no build-in calculus functions in C++.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|