|
Hi,
Sorry if the question was not clear
I have a menu which is activated in a window with right mouse button click.When the menu appears the user selects a menu option .I want to find out which menu option has been selected from the menu.
Prithaa
|
|
|
|
|
Hello,
all menu items have an identifier, you must to use them to find which menu item has been klicked!
Is that what you mean?
regards
break;
|
|
|
|
|
If you pass the TPM_RETURNCMD flag to TrackPopupMenu() , then the return value indicates what was selected. If you don't use that flag, your window will get a WM_COMMAND message just as if the menu bar had been used.
|
|
|
|
|
Hi,
thanks
I got What has to be done
Prithaa
|
|
|
|
|
If I only know the DIO device is at port 280.
How can I access it? (read / write the pins)
NO API is available.
Please help!
Any relative information is welcome.
Thanks!
|
|
|
|
|
Assuming you're running some windows environment, you'll need a device driver for your device. You're not allowed to access the hardware from user mode.
Since you clearly state that "NO API is available", I assume you don't have a driver for your device and you've possibly made the device yourself.
If you bought the device it should be shipped with a device driver, unless it registers itself as a common device such as a COM port, in which case you can use ::CreateFile(), ::ReadFile(), ::WriteFile(), ::CloseHandle() and such to access it.
If you don't know anything else about the device besides the I/O port: give it up, there's no way to guess.
However, if you know how the device works and how to communicate with it at low level, you can develop a device driver of your own.
This way is quite hard, but if you'd like to have a go for it, start by reading Toby Opfermans article serie about device driver development here[^].
Hope this helps
--
Roger
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"No one remembers a coward!" - Jan Elfström 1998 "...but everyone remembers an idiot!" - my lawyer 2005 when heard of Jan's saying above
|
|
|
|
|
The device is together with the PC on delivery.
And it works in the debug mode.
eg. type "-o 280 F1" as a command
I just dont know how to access it using cpp.
So, I think I can use ::CreateFile(), ::ReadFile(), ::WriteFile(), ::CloseHandle() to access it, right?
More question, using ::CreateFile, should I use "port280" as the file name?
Thanks very much!
|
|
|
|
|
Archyami wrote: just dont know how to access it using cpp.
So, I think I can use ::CreateFile(), ::ReadFile(), ::WriteFile(), ::CloseHandle() to access it, right?
More question, using ::CreateFile, should I use "port280" as the file name?
If you open a device with ::CreateFile(), you have to provide the device name as argument to the function, e.g. "COM1" when opening communications port 1.
You have to find out what your device is called before you can access it through these methods. Look for settings in the Device Manager.
It's not possible for anyone else to know what your device is called in your machine. Perhaps if you mentioned what kind of device it is someone could tell you how the device usually presents itself and how to communicate with it.
--
Roger
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"No one remembers a coward!" - Jan Elfström 1998 "...but everyone remembers an idiot!" - my lawyer 2005 when heard of Jan's saying above
|
|
|
|
|
Hi,
I'd like to save the Z order of all windows. In fact, i'm working on a HideAll windows and ShowAll.
That's why i'd like to save this z-order to get the windows restaured in the same order.
thanks
|
|
|
|
|
|
ENumWindows and store the Window Handle in the array!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And You
|
|
|
|
|
Hi everyone,
it's possible to set on creation a specific RGB-Value as Backgroundcolor for a CFormView.
Is it also possible to change the backgroundcolor at runtime? for example by clicking a button?
If i change the brush like this m_bgrBrush.CreateSolidBrush(RGB(255,255,255)); it crashes during the click-event
Thanks
|
|
|
|
|
You can use of a variable on m_bgrBrush.CreateSolidBrush(yourcolor);
|
|
|
|
|
If i change the brush like this m_bgrBrush.CreateSolidBrush(RGB(255,255,255)); it crashes during the click-event
You can use of a variable on m_bgrBrush.CreateSolidBrush(yourcolor);
______________________________________________________________________________________________________
That's the problem, it will not work.
If i change a variable that's used in OnCtlColor it doesn't work also
HBRUSH FEinstellungenView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
if((nCtlColor == CTLCOLOR_STATIC) || (nCtlColor == CTLCOLOR_DLG) )
{
// Ändert
pDC->SetBkColor(MyColor); // MyColor is a DWORD that i change in the click-event MyColor = RGB(255,255,255)
return (HBRUSH) m_bgrBrush;
}
return hbr;
}
Thanks
|
|
|
|
|
You get an error because you created CBrush prevoius CreateSolidBrush .You can declare a variable for color like:COLORREF color; color=RGB(0,0,100);
|
|
|
|
|
BOOL FEinstellungenView::OnEraseBkgnd(CDC* pDC)
{
CRect rcClient;
GetClientRect( &rcClient );
pDC->FillRect(rcClient, &CBrush(*MyColor)); // On the click i change the MyColor Value
return TRUE;
}
Thats the easiest way i think
I found it after a long Google Research
Thanks nevertheless
|
|
|
|
|
Or you can use pDC->FillRect(rcClient, &CBrush(MyColor));
|
|
|
|
|
Hi,
try this, it worked very well by me. hope it helps
HBRUSH CPickOColorDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
switch( nCtlColor )
{
case CTLCOLOR_BTN:
break;
case CTLCOLOR_STATIC: //if you have some static text
pDC->SetBkMode( TRANSPARENT );
return static_cast<hbrush>( m_brBack.GetSafeHandle() );
break;
case CTLCOLOR_DLG: // for the form view / dialog view
return static_cast<hbrush>( m_brBack.GetSafeHandle() );
break;
case CTLCOLOR_EDIT:
break;
}
return hbr;
}
void CPickOColorDlg::OnBnClickedButtonColor()
{
m_brBack.DeleteObject();
m_brBack.CreateSolidBrush(RGB(255,0,0));//red
Invalidate(TRUE);
}
pasnad
|
|
|
|
|
In my application when i press a button a file open dialog box with files of particular type will open and from that if i select a item and press open button in that file open dialog box i am getting an error "I_Flapp MFC Application has encountered a problem and needs to close. We are sorry for the inconvenience.".Can any one knows why this error comes and how can we rectify it.
Thanks.
|
|
|
|
|
Did you try debugging and find where exactly the error occurs? And can you post the code here?
|
|
|
|
|
I have written the code like this to open the document files when button is pressed,
static TCHAR BASED_CODE szFilter[] = "Windows Setup file (*.pdf;*.xml)|*.pdf;*.xml||";
CFileDialog oFileDlg(TRUE,"pdf","",OFN_FILEMUSTEXIST|OFN_NOCHANGEDIR, szFilter);
oFileDlg.m_ofn.lpstrTitle = "Select the Installable Application";
if(oFileDlg.DoModal() == IDOK)
{
m_install.m_strSetup = oFileDlg.GetPathName();
GetDlgItem(IDC_SETUP)->SetWindowText(m_install.m_strSetup);
}
|
|
|
|
|
This code is alright. Did you not try debugging? What is m_install? Comment the last line and see if it works.
|
|
|
|
|
when i dedugged the error is coming after that line.It is working in one system and but not in the other.
Thanks.
|
|
|
|
|
radhika28 wrote: when i dedugged the error is coming after that line.
Which line? Am I supposed to guess it?
radhika28 wrote: It is working in one system and but not in the other.
Check out the dependencies.
The nail that stands out will be hammered down
|
|
|
|
|
I asked you what is m_install. Is that a CString or char* or what? Did you try using a CString variable there, instead of a member variable?
|
|
|
|