|
I am writing a WinAPI app and trying to use some code to make a systray icon. However, when I pass in the HWND into the class as below:
.h
public:<br />
HWND m_hParentWnd;
.cpp
void CTrayIcon::OnCreate(HWND parent, UINT uCallbackMessage, HICON icon)<br />
{<br />
m_hParentWnd = parent;
there is an unhandled exception:
Unhandled exception at 0x00415799 in blueline.exe: 0xC0000005: Access violation writing location 0x00000004.
The contents of parent is:
parent: 0x000b0d30 {unused=??? }
unused = CXX0030: Error: expression cannot be evaluated
It wuld be amazing if someone could suggest a direction to look in. I have found somebody with a similar problem, but they didn't get a responce.
Nicola.
|
|
|
|
|
can you show us the code where you create your CTrayIcon instance, and when you call Create ?
|
|
|
|
|
In most of the cases, this is due to the fact that you are manipulating a pointer to a CTrayIcon instance, and this pointer is NULL.
|
|
|
|
|
Do you mean if you comment out this line
m_hParentWnd = parent; then everything works fine?
parent: 0x000b0d30 looks like a valid windows handle. no problem with that.
Since you are getting write access violation, it means you are trying to write to an invalid location, now which location is that and why it is invalid seems hard to tell with the information you have provided..
|
|
|
|
|
Okay, I was looking in the wrong place for issues. The CTrayIcon object isn't being set up correctly. Thank you all for your help, it's really appreciated!
Nicola.
|
|
|
|
|
Dear All,
I am not able to Find the Wrong with the Following Code.
Please Help me out.
SQLHENV envHandle;
SQLHDBC ConnHandle;
SQLHSTMT StmtHandle;
SQLRETURN Ret;
SQLSMALLINT szConnStroutlen;
SQLCHAR sZ_AuthorName[50];
SDWORD sdoutputDataLen;
unsigned char szConnStrout[255];
Ret = ::SQLAllocEnv(&envHandle);
Ret = ::SQLAllocConnect(envHandle,&ConnHandle);
Ret = ::SQLDriverConnect(ConnHandle,
NULL,(SQLWCHAR *)_T("Driver={Microsoft Access Driver (*.mdb)}; DBQ=C:\\Uday.mdb"),
SQL_NTS,(SQLWCHAR*)szConnStrout,sizeof(szConnStrout),&szConnStroutlen,SQL_DRIVER_NOPROMPT);
Ret = ::SQLAllocStmt(ConnHandle,&StmtHandle);
//To Fetch a Relative Record.
Ret = SQLFetchScroll(StmtHandle,SQL_FETCH_FIRST,0); //The Code is Failing here.
Thanks & Regards,
Uday.
|
|
|
|
|
janaswamy uday wrote: Ret = SQLFetchScroll(StmtHandle,SQL_FETCH_FIRST,0); //The Code is Failing here.
Why?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
janaswamy uday wrote: Ret = SQLFetchScroll(StmtHandle,SQL_FETCH_FIRST,0); //The Code is Failing here.
According to thedocumentation[^], you should be looking into the return value of the function, and then based on the return value, you should be able to identify the reason for failure (if any). Have you done the diagnostics? Why does it fail?
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Dear Rajesh,
If i really know why should i post this message. I have really Struk with this. If you have any Idea please Help me Out. I am in deep trouble. I want to know this Concept. Please Help Me Out with proper Solution.
Thanks & Regards,
Uday.
|
|
|
|
|
janaswamy uday wrote: If i really know why should i post this message. I have really Struk with this. If you have any Idea please Help me Out. I am in deep trouble. I want to know this Concept. Please Help Me Out with proper Solution.
I'm sorry to know that you're in deep trouble.
The said function returns a value that you should check. If the function fails, the return value actually tells why did it fail so. Take a look at the "diagnostics" section of the documentation page to know more.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
I use Win32 Dynamic-Link Library and I would like to create a member that can show something like a MessageBox with OK button (Exit), it also shows a message (ie: "Please enter your comments in the User Input") and a TextBox input.
After the user entering his/her comments then hits OK button, it will return the user input!
Do we have any thing available like that? If not, might anyone help me on this?
Thanks in-advanced
|
|
|
|
|
THAQCD wrote: Do we have any thing available like that? If not, might anyone help me on this?
Yes it's called a Dialog Box[^] (CDialog if MFC).
|
|
|
|
|
Hi Richard,
I am trying to get any codes related to your link (only information) & others in order to create a Dialog box from my Win32 Dynamic-Link Library project ... but couldn't find any thing yet!
Any suggestion?
Thanks for help
|
|
|
|
|
The link he gave you was a good one. The fact you're asking a basic question (nothing wrong with being at the start of something) means you have a lot of learning to do. The link he gave you is Microsoft's explanation of the concepts.
There are many links throughout that article pointing to more specific things.
As for an actual function?
Try: DialogBox, or CreateDialog.
You'll also need a Dialog resource. And if you're in pure Win32, you'll have to learn about instance handles.
(All of this is googlable - I'm trying to give you search terms)
If you're starting from nothing, then this is not easy stuff. Don't expect to solve it in 10 minutes.
Also, you cannot expect someone here to write "codez" for you that will do exactly what you want. What he was trying to do was to steer you at learning material so you can do it yourself - or at least start to, and ask more detailed questions later.
Good luck,
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Thank for the advice, actually I am trying to learn how to do it now and you are right so far I have spent more than 1 hour to try
|
|
|
|
|
Only an hour?
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
|
Hi, i am new to Visual C++ and facing problem with combo boxes.
Here is what i need:
Combobox1
Choice: Metal, Plastic
Combobox2
Choice: if Metal in Combobox1: 2,3,4,5,6
Choice: if Plastic in Combobox1: 8,10,15
I am unable to write code for the event, can any one help me out with the hints or links or code!...any help is highly appreciated...!
#pragma once
namespace PR {
using namespace System; using namespace System::ComponentModel; using namespace System::Collections;
using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{ InitializeComponent();
}
protected:
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::ComboBox^ comboBox1;
protected:
private: System::Windows::Forms::ComboBox^ comboBox2;
private:
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->comboBox2 = (gcnew System::Windows::Forms::ComboBox());
this->SuspendLayout();
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^ >(2) {L"METAL", L"PLASTIC"});
this->comboBox1->Location = System::Drawing::Point(81, 80);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System::Drawing::Size(121, 21);
this->comboBox1->TabIndex = 0;
this->comboBox1->Text = L"METAL";
this->comboBox2->FormattingEnabled = true;
this->comboBox2->Items->AddRange(gcnew cli::array< System::Object^ >(5) {L"2", L"3", L"4", L"5", L"6"});
this->comboBox2->Location = System::Drawing::Point(81, 126);
this->comboBox2->Name = L"comboBox2";
this->comboBox2->Size = System::Drawing::Size(121, 21);
this->comboBox2->TabIndex = 1;
this->comboBox2->Text = L"2";
this->comboBox2->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox2_SelectedIndexChanged);
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292, 266);
this->Controls->Add(this->comboBox2);
this->Controls->Add(this->comboBox1);
this->Name = L"Form1";
this->Text = L"Form1";
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void comboBox2_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
}
};
}
modified on Monday, October 19, 2009 10:27 AM
|
|
|
|
|
you'd probably need to post this in the "Managed c++/cli" forum.
anyway, there's stuff missing from you post.
This signature was proudly tested on animals.
|
|
|
|
|
Hi Maximilien
Please find the complete code now, or should i post it on "Managed C++/CLI" forum?
Any help is appreciated. Thanks
|
|
|
|
|
Invinci wrote: should i post it on "Managed C++/CLI" forum?
yes.
This signature was proudly tested on animals.
|
|
|
|
|
My MFC applicatin crashes with this call stack info.
Can anyone please help me out in understanding this?
ntdll!KiUserExceptionDispatcher+e
<Unloaded_RapidEyeAPI.dll> +1e701
ntdll!ExecuteHandler2+26
ntdll!ExecuteHandler+24
ntdll!KiUserExceptionDispatcher+e
<Unloaded_RapidEyeAPI.dll> +1e701
ntdll!ExecuteHandler2+26
ntdll!ExecuteHandler+24
ntdll!KiUserExceptionDispatcher+e
<Unloaded_RapidEyeAPI.dll> +1e701
ntdll!ExecuteHandler2+26
ntdll!ExecuteHandler+24
ntdll!KiUserExceptionDispatcher+e
<Unloaded_RapidEyeAPI.dll> +1e701
ntdll!ExecuteHandler2+26
ntdll!ExecuteHandler+24
ntdll!KiUserExceptionDispatcher+e
<Unloaded_RapidEyeAPI.dll>+271d
ntdll!RtlpAllocateFromHeapLookaside+42
<Unloaded_RapidEyeAPI.dll>+39f3
ntdll!RtlpAllocateFromHeapLookaside+42
<Unloaded_RapidEyeAPI.dll>+1c999
ntdll!RtlpAllocateFromHeapLookaside+42
kernel32!BaseThreadStart+37
modified on Monday, October 19, 2009 9:13 AM
|
|
|
|
|
Could you solve your problem?
BaseThreadStart is indicating that you are creating a new thread?
|
|
|
|
|
Hi all,
I have written a program which can monitor a specific program when it was closed.I used hook to do it and everything seem be ok but the problem is that I cannot hook WM_CLOSE message.
I have tried to use WH_GETMESSAGE, WH_CBT, WH_CALLWNDPROC. But all of them seem not work properly!
here is my code:
hHook = SetWindowsHookEx(WH_CALLWNDPROC,fnHookProc,hInstDLL,tid);
DLLEXPORT LRESULT CALLBACK KeyboardProc(int nCode,WPARAM wParam, LPARAM lParam)
{
LPMSG msg = (LPMSG)lParam;
if(msg->message == WM_CLOSE )
{
}
return CallNextHookEx(_hHook,nCode,wParam, lParam);
}
anybody help me.
thanks
[N][Q][H]
|
|
|
|
|
There must be something special about the WM_CLOSE message. Are you using a DLL? Are you calling SetWindowLong() in that DLL? Are you injecting the DLL into the process of the "specific window?"
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|