|
I have creted one callback method
int MYAPI CALLBACK Init(HWND hWnd)
{
}
inside the dll.
Inside main application user first need to call Init whenever he loads the application.
abhi
|
|
|
|
|
I am able to postMessage from DLL, even application did'nt crash for Invalid window handle, What does MR. Debugger says. I think it is not the postmessage causing the access violation. post code snippet.
|
|
|
|
|
yaa I am also able to PostMessage inside Init fuction but i want to PostMessage by
see below
#include "Work.h"
CWORK *pObj=NULL;
HWND hMyWnd;
MYAPI int CALLBACK Init(HWND hWnd)
{
hMyWnd=hWnd;
pObj=new CWORK();
}
in WORK.h
#define WM_MYMSG WM_APP+10001
class CWork
{
public:
CWORK();
~CWORK();
Initialize();
}
In WORK.cpp
UINT ThreadMyProc(LPVOID lpObject);
HANDLE hThread=NULL;
extern HWND hMyWnd;
void CWORK::Initialize()
{
hThread = CreateThread(
NULL, // default security attributes
0, // use default stack size
ThreadMyProc, // thread function
(LPVOID)this, // argument to thread function
0, // use default creation flags
dwThreadId); // returns the thread identifier
}
}
UINT ThreadMyProc(LPVOID lpObject)
{
CWORK pWork=(CWORK*)lpObject;
while(true)
{
some conditions...
then I use
PostMessage(hMyWnd,WM_MYMSG,0,0x002);
}
return 0;
}
so as shown above when I PostMessage from ThreadMyProc it shows error in main application
Please check and give me suggestion anything wrong in this code and if possible givw solution that how we can post message from thread to main application.
abhi
|
|
|
|
|
AbhijitAkude wrote: yaa I am also able to PostMessage inside Init fuction
I see this in your first post itself, In my previous post i mean i can able to post message in the thread procedure.
AbhijitAkude wrote: so as shown above when I PostMessage from ThreadMyProc it shows error in main application
if crash occurs in DLL procedure application is blamed as both are one process, any way how do you conclude PostMessage is the issue, what debugger says. the above code doesn't give any hint to me, I think Initialize is called within the constructor of CWORK, what is the error you see which statement debugger points to.
|
|
|
|
|
The error is "Unhandled exception in main.exe(Mydll.dll):0xC0000005:Acess violation
I am using Win32 Application=>Windows Hello world application.
And the main.exe shows and error
abhi
|
|
|
|
|
I am repeating, to use debugger. Access violation are easily caught by debugger. How you are saying postmessage is the culprit. Does debugger points there, [Debug Tips^].
what is there in <some condition> before calling postmessage, how do you call CWORK::Initialise.
|
|
|
|
|
Hello dear friends,
I am developing a toolbar.
I've included the menu in the project's resource file.
I want to dispaly this menu when a button of toolbar clicked.
I've made the button with BTNS_WHOLEDROPDOWN style.
I want to display the floating menu using TrackPopupMenu.
the problem is when I load the menu using LoadMenu this function fails and
GetLastError() returns "The specified resource type cannot be found in
the image file" I don't understand the problem.Please help me out.
Thanks in Advanced.
ritz1234
|
|
|
|
|
have you used MAKEINTRESOURCE() to specify the Integer resource ID.
post the code snippet.
modified on Saturday, May 10, 2008 3:29 AM
|
|
|
|
|
Hi all,
I have made a apllication using vc2005, my problem is its running on some machine and on some machine its giving error
the application has failed to start because its side by side configuration is incorrect. Please see the application event log for more details....
I have serched on google they have told to install the Microsoft Visual C++ 2005 Redistributable Package.
i have done it but still the problem persists
Can anybody help me in this...
Thanks in advance
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
which binary you are trying to run, is that release configured or debug configured.
Redistributable is available only for release build.
|
|
|
|
|
I have tried it using both realease and debug mode but the problem still persists...
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Hi,
In normal DLL, to export a function we place extern "c" __declspec(dllexport) before the funtion prototype.
Can any one tell me what this extern "c" indicates and what happens if we don't use extern "c" before __declspec while exporting and importing the function.
Thanks in advance.
|
|
|
|
|
|
extern "C" makes the function exported using C-like mangling scheme (instead of C++ one), this is, for instance, the standard for Win32 API .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
extern <string literal> specifies the external linkage that its name is visible outside the file in which it is defined, Microsoft C++ supports the strings "C" and "C++" in the string-literal field to specify the linkage convention of other languages, you can link to the function, if the linkage conventions are same.
|
|
|
|
|
I use this code to create a value in Registry:
CString strValue;
DWORD dwBytes ;
LPBYTE lpData ;
strValue=_T("1doandaithietladaidaihoncaidoanhoinaylunnecoithumaychaydcko?");
dwBytes = strValue.GetLength()+1;
lpData = (LPBYTE) strValue.GetBuffer(dwBytes);
::RegSetValueEx(m_hSectionKey, _T("Test"), NULL, REG_SZ, lpData, dwBytes);
But the value data in Registry is just : "1doandaithietladaidaihoncaidoa"
Someone plz help me to explain & give me a solution
|
|
|
|
|
Your building a UNICODE application hence each character is 2 bytes wide.
The correct value for dwBytes is:
dwBytes = (strValue.getLength()+1)*sizeof(TCHAR);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
And see this[^] article for more help.
|
|
|
|
|
Oh It worked, thanks so much
|
|
|
|
|
Why are you calling GetBuffer() ? Unless you are also modifying strValue , it is unnecessary and potentially dangerous.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Good point.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi,
I and writing MFC application for Mobile 6 on HP iPAQ.
When I tap on the screen (with stylus) and continue to hold it (TAP and HOLD), a circle of "small solid circles" appear. I do not want to implement any context menu; instead I want this circle of "small solid circles" to disappear.
I am thinking that if I can somehow catch an even for "TAP and HOLD" I can avoid this.
If you could let me know how to do this I would greatly appreciate it.
Thanks!
-A
|
|
|
|
|
|
I am tring to write a class that defines location based on latitude & longitude. I have searched high and low with no such luck. Can anyone help?
|
|
|
|
|