|
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?
|
|
|
|
|
You have to iterate the list first to get all the selected items positions. Once you have that list go through it backwards to delete all the indexes as deleting them in the order you receive them changes the indexes of the following items.
int count = m_UsingList.GetSelectedCount();
if (count > 0)
{
int *pIndexes = new int[count];
int index = 0;
POSITION pos = m_UsingList.GetFirstSelectedItemPosition();
while (pos)
{
pIndexes[index++] = m_UsingList.GetNextSelectedItem(pos);
}
for (index = count - 1 ; index >= 0 ; index--)
{
m_UsingList.DeleteItem(pIndexes[index]);
}
delete []pIndexes;
pIndexes = NULL;
}
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.
|
|
|
|
|
Here are two ways:
for (int x = 0; x < m_list.GetItemCount(); x++)
{
int nItem = m_list.GetNextItem(-1, LVNI_SELECTED);
BOOL bStatus = m_list.DeleteItem(nItem);
}
and
int nItem = m_list.GetNextItem(-1, LVNI_SELECTED);
do
{
BOOL bStatus = m_list.DeleteItem(nItem);
nItem = m_list.GetNextItem(nItem - 1, LVNI_SELECTED);
} while (nItem != -1);
The latter is a tad faster as it does not have to continually search from the beginning of the list for a match.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
It works fine Thank you!
I am suprised that there is so many ways to delete multiple files in a listbox, and I could not pick any of them
Thats the cool way of programming sometimes you know so much and so litle!
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?
|
|
|
|
|
"DeleteItem" makes indices of all subsequent items decrease by one, so suppose the "next selected item" had index of 5, it could become 4 after a call of "DeleteItem". So you should do this instead:
m_ListControll.LockWindowUpdate();
POSITION p = m_ListControll.GetFirstSelectedItemPosition();
while (p)
{
m_ListControll.DeleteItem(m_ListControll.GetNextSelectedItem(p));
p = m_ListControll.GetFirstSelectedItemPosition();
}
m_ListControll.UnlockWindowUpdate();
Simply keep deleting the first selected item until there's no more, you really don't need to make things complicated, such as establishing an additional array.
|
|
|
|
|
I have 3 classes
CFirst : CButton
CSecond : CFirst
CThird : CSecond
CSecond::OnTimer() sends the parent window a message using:
WPARAM wParam = MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED);
GetParent()->SendMessage(WM_COMMAND, wParam, this);
I'm trying to notify the parent that this particular button was clicked, but i have 2 problems/questions:
1) How can I send the
this</code pointer? When I cast it as long woun't it loose it's RTTI? I need this for later :)<br />
<br />
2) When the parent recieves <code>WM_COMMAND messages is there anyway the parent window can determine using the this pointer which class derived from CButton was clicked? CSecond or CThird
Will the parent be able to determine that it was a CSecond clicked or a CThird clicked??? or will it always get the CSecond ? Do I have to make CSecond::OnTimer virtual?
Thanks in advance
I'm drinking triples, seeing double and acting single
|
|
|
|
|
1. The notification is done only by window handle. For SendMessage, you should use something like
GetParent()->SendMessage(WM_COMMAND, wParam, (LPARAM)GetSafeHwnd());
2. It could examine the control ID, assuming you know at runtime which IDs are associated with each kind of button. The virtuality of OnTimer won't help. The sink (target) for the message must be able to work it out itself.
Steve S
|
|
|
|
|
Steve S wrote:
GetParent()->SendMessage(WM_COMMAND, wParam, (LPARAM)GetSafeHwnd());
I Initially had that, but figured sending a generic window handle to my parent wouldn't allow me to use RTTI Unless I has code in my parent class that would create the appropriate object (CSecond or CThird) and attach the windows handle. Not quite the solution I wanted. I think i'll just use command ID's
Thanks again
Cheers
I'm drinking triples, seeing double and acting single
|
|
|
|
|