|
How to handle right mouse button click in menu? (like "favorites" menu in IE)
|
|
|
|
|
|
hi,
I've problems with those two funcions they fails giving me error code number
1813 The specified resource type cannot be found in the image file.
and they're used here.....
wclass.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(ICON));
.... and here ....
case WM_CREATE:
hInst = (HINSTANCE)GetWindowLong(hWnd,GWL_HINSTANCE);
hMenu = (HMENU) LoadMenu(hInst,MAKEINTRESOURCE(MENU));
hMenu = GetSubMenu(hMenu,0);
MENU and ICON are defined as resource but I can't explain why the two funcions above fail, maybe it's due to MAKEINTRESOURCE? is there another way to load resources?
thanks in advance
|
|
|
|
|
My first thought is that you are having an EXE/DLL instance handle problem. To double check, you
could use GetModuleFileName to double check which module is being pointed at by the hInst. You can
then double check that your resources are really there, and not in another module of the process.
I would also pick better names than ICON and MENU. I assume you just put them in your post rather than
in your code?
Iain.
|
|
|
|
|
how to check if resource are in the module of the process? for Icon I succeded in, no way for Menu..... names are called ICON and MENU for faster writing in the post,
thanks
|
|
|
|
|
Dear friends,
In my simple dialog based application i placed a rich edit control.
I also derived my custom class from CRichEditCtrl:
CMyRichEditCtrl: public CRichEditCtrl { ...
I want to get EN_CHANGE notification whenever there is some text typed in the box. I am successfully getting it
But the problem is that i want to capture this EN_CHANGE notification in PreTranslateMessage() of my Main dialog class or my custom CMyrichEditCtrl class. Very strange that this message is not appearing in PreTranslateMessage() of either classes.
Can anyone tell me whats the problem.
|
|
|
|
|
There is no such message as EN_CHANGE. You need to look for WM_COMMAND, with a WPARAM of EN_CHANGE, and the right window handle in LPARAM.
Steve S
|
|
|
|
|
Steve
I have tried the following code after calling the SetEventMask with ENM_CHANGE ored with the previous mask.
<br />
void CMyDialog::PreTranslateMessage(MSG *pMsg)<br />
{<br />
if (pMsg->message == WM_COMMAND && HIWORD(pMsg->wParam) == EN_CHANGE<br />
&& (HWND)pMsg->lParam == m_reObj.m_hWnd)<br />
{<br />
TRACE("EN_CHANGE received\n");<br />
}<br />
}<br />
But this doesnt work, i even tried to replace the above condition with this
<br />
void CMyDialog::PreTranslateMessage(MSG *pMsg)<br />
{<br />
if (pMsg->message == WM_COMMAND)<br />
{<br />
TRACE("EN_CHANGE received\n");<br />
}<br />
}<br />
But still no luck. I tried to subclass the control with a custom rich edit class and setup the message handler for EN_CHANGE and Voala i was receiving the message in OnChange() but i am unable to receive it in my PreTranslateMessage so what is wrong here.
Regards
-Saad
|
|
|
|
|
Hi!
There is a function in CBitmap class, LoadBitmap() . However, it only takes resourceID as a parameter i.e it only attaches that bitmap with CBitmap object which is present in the resource.
I like to attach a bitmap to CBitmap object, which is not present in resource, but is in some bmp file. How can i do so
|
|
|
|
|
Try this
HBITMAP CYourClass::LoadBitmapFromFile(LPCTSTR szFilename)
{
HBITMAP hbmp;
hbmp = (HBITMAP)LoadImage(NULL, szFilename, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
return hbmp;
}
He believed the commercials that said drink beer, get laid
but at closin' time he was alone, he didn't get paid.
Last night his lover was a razorblade..
"Dan Reed song Mix it up"
What do you want to patch today?
|
|
|
|
|
i want to access mysql database using C , i read the documentation which is there on mysql site , but where to get the required files like mysql.h and ,lib files.
My MySql database is on linux machine and i want to access it from Windows machine. My program which is accessig the mysql data is written in c and is on Windows platform.I have already installed the required mysql driver, but to use the mysql API's i require mysql.h file . Do i require any other files for that, if so please let me this in detail.
Suvarna
|
|
|
|
|
You can access mysql through ODBC and you wont need the mysql.h file. You find the mysql odbc in the mysql site. Install it on your windows machine and then make a connector in the windows odbc. Then you connect to the linux mysql from you program through the odbc connector.
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
I'm using Visual C++ 6.0 SP5
I create a new MFC Appwizard project, I choose SDI with doc/view architecture support, then I leave everything at the defaults until it asks me How do you want your toolbars to look? and I choose Internet Explorer Rebars then finish.
In the resource editor under dialogs I edit the IDR_MAINFRAME dialog and add a button to it. I double click my newly created button to add an onclick handler. Classwizard pops up with a message saying IDR_MAINFRAME is a new resource... do you want to add a class for it? and I choose create a new class. Then I give this new class a name and leave everything at the defaults and push OK. Now I close Classwizard and go back to the resource editor and double click my button again to add the event handler. This time it prompts me for the name of the event handler and I just leave it as the default OnButton1. Then in the code for the event handler I just put something simple to test out the button like AfxMessageBox("bleah");
I run the program and the button is grayed out...
If I add an activex control to the dialog it will be enabled but the event handlers will be ignored.
anybody know why?
I am stumped...
since microsoft sucks I bet that the new dialog class it creates is somehow messed up but I'm a bit of a beginner so I can't really tell a messed up class from a good one and I can't tell a message map from my own butt.
Any ideas are appreciated.
-Oinka
|
|
|
|
|
Standrad MFC routing code will automatically disable menu/toolbar item if it command find a message handler in any of the following classes:
CYourApp
CMainFrame
CYourDoc
CYourView
As you chose "Create a new class..." when associating the message OnButton1() handler, you probably did not get it put in the message map for one of these classes. What you should have done is "Select an existing class", which is probably CMainFrame or CYourDoc depdning on what you want to do.
Typically if you need the handler to go in a specific class, I would start up class wizard and select the class you want the handler in. Then select the correct menu/toolbar button id and create a message map handler that way.
Roger Allen
Sonork 100.10016
Death come early, death come late,
It takes us all, there is no reason.
For every purpose under heaven,
To each a turn, to each a season.
A time to weep and a time to sigh,
A time to laugh and a time to cry,
A time to be born and a time to die.
Dust to dust and ashes to ashes,
And so I end my song.
|
|
|
|
|
|
DirectShow Problem
Error return 'E_INVALIDARG' when calling ICaptureGraphBuilder2::RenderStream
at the second try.
My program flow is about :
1. (Application Initial)
Enumerate the capture devices and store the IMoniker pointer in a list.
*repeat
2. whenever creating new Class 'MyClass', I start to
a. build the Filter Graph(CLSID_FilterGraph)
b. build the Capture graph(CLSID_CaptureGraphBuilder2)
c. get IMediaControl, IVideoWindow, IMediaEvent from calling IGraphBuilder::QueryInterface.. etc....
d. get a IMoniker point from IMoniker list(built at first step.) to bind an SourceFilter
e. add the sourcefilter to the graph
f. call ICaptureGraphBuilder::RenderStream (return 'E_INVALIDARG' at the second try)
3. Destroy 'MyClass' object.
a. release all: IGraphBuilder, ICaptureGraphBuilder2, IMediaControl, IVideoWindow, IMediaEvent...
*end repeat
The problem is when I 'retry' to create a MyClass from step 2, the return value of the
function call 'ICaptureGraphBuilder::RenderStream' is turned to 'E_INVALIDARG', but all
is fine at the first time.
Is anyone have the same problem with me? Or something should be noticed I missed.
---program segment---
class MyClass<br />
{<br />
....<br />
public:<br />
IVideoWindow *g_pVW;<br />
IMediaControl *g_pMC;<br />
IMediaEventEx *g_pME;<br />
IGraphBuilder *g_pGraph;<br />
ICaptureGraphBuilder2 *g_pCapture;<br />
......<br />
public:<br />
MyClass()
{<br />
InitialVideo();<br />
}<br />
HRESULT InitialVideo();<br />
}<br />
<br />
HRESULT MyClass::InitialVideo()<br />
{<br />
HRESULT hr;<br />
hr = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void **) &g_pGraph);<br />
ErrorCheck (hr);<br />
hr = CoCreateInstance (CLSID_CaptureGraphBuilder2 , NULL, CLSCTX_INPROC, IID_ICaptureGraphBuilder2, (void **) &g_pCapture);<br />
ErrorCheck (hr);<br />
hr = g_pGraph->QueryInterface(IID_IMediaControl,(LPVOID *) &g_pMC);<br />
ErrorCheck (hr);<br />
hr = g_pGraph->QueryInterface(IID_IVideoWindow, (LPVOID *) &g_pVW);<br />
ErrorCheck (hr);<br />
hr = g_pGraph->QueryInterface(IID_IMediaEvent, (LPVOID *) &g_pME);<br />
ErrorCheck (hr);<br />
hr = this->g_pCapture->SetFiltergraph(this->g_pGraph);<br />
ErrorCheck (hr);<br />
POSITION pos = this->m_capturefilterList.FindIndex(uDevId);<br />
if (pos == NULL) return E_FAIL;<br />
IMoniker *pM = (IMoniker *)this->m_capturefilterList.GetAt(pos);<br />
if (pM == NULL) return E_FAIL;<br />
IBaseFilter *pSrc = NULL;<br />
hr = pM->BindToObject(0, 0, IID_IBaseFilter, (void**)&pSrc);<br />
ErrorCheck (hr);<br />
hr = g_pGraph->AddFilter(pSrc, L"Video source");<br />
ErrorCheck (hr);<br />
hr = g_pCapture->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, pSrc, NULL, NULL);<br />
<br />
ErrorCheck (hr);<br />
pSrc->Release();<br />
return hr;<br />
}
|
|
|
|
|
Is there an easy way to route all messages from a child to it's parent's parent?
Can I do something like:
((GetParent())->GetParent())->SendMessage(WM_COMMAND);
I guess I could just try it, but i'm not home right now, so I can't yet...
Also i'd lik,e to see if you have a better approach???
Like override parent::OnCommand, PreTranslateMessage, etc and just route from there to it's parent...incase each message may need special handling first before being sent to it's parent parent???
Thanks again!
I'm drinking triples, seeing double and acting single
|
|
|
|
|
You can use the message reflection macros - that might be a "cleaner" (and easier) solution. I used this technique in a CWnd derived class I built that hosted a few controls.
My object received click and double-click notifications and decided what to do with them (when an item in the embedded list control was selected by the user, items in an embedded tree control were automatically selected).
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thanks
I'll look into it
Cheers
I'm drinking triples, seeing double and acting single
|
|
|
|
|
Hello!
Is there someone here who can tel my why this is not working for me.
I want to delete some selected items in a ListControl, But It only deletes
a few of them not all of them??
POSITION p = m_ListControll.GetFirstSelectedItemPosition();
while (p)
{
m_ListControll.DeleteItem(m_ListControll.GetNextSelectedItem(p));
}
He believed the commercials that said drink beer, get laid
but at closin' time he was alone, he didn't get paid.
Last night his lover was a razorblade..
"Dan Reed song Mix it up"
What do you want to patch today?
|
|
|
|
|
Look up GetNextSelectedItem() in MSDN.
|
|
|
|
|
I would have thought that DeleteItem() would have a very noticeable side-effect on the current selection. Consider assigning item data's to the list control entries and using that to identify candidates for deletion.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I tryed that to i did not work!
He believed the commercials that said drink beer, get laid
but at closin' time he was alone, he didn't get paid.
Last night his lover was a razorblade..
"Dan Reed song Mix it up"
What do you want to patch today?
|
|
|
|
|
Try this:
for (long nItem=0; (nItem < m_listCtrl.GetItemCount()); nItem++)
m_listCtrl.SetItemData (nItem, nItem);
CUIntArray selectedItems;
POSITION pos = m_listCtrl.GetFirstSelectedItemPosition();
while (pos != NULL) {
long nIndex = m_listCtrl.GetNextSelectedItem (pos);
selectedItems.Add (nIndex);
}
for (nItem=0; (nItem < selectedItems.GetSize(); nItem++) {
for (long nIndex=0; (nIndex < m_listCtrl.GetItemCount(); nIndex++)
if (m_listCtrl.GetItemData (nIndex) == selectedItems.GetAt (nItem)) {
m_listCtrl.DeleteItem (nIndex);
break;
}
}
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thank you!
I tryed something similar but I never used the CUIntArray.
This works Thank you again!
/Jarek
He believed the commercials that said drink beer, get laid
but at closin' time he was alone, he didn't get paid.
Last night his lover was a razorblade..
"Dan Reed song Mix it up"
What do you want to patch today?
|
|
|
|