|
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?
|
|
|
|
|
After m_install.m_strSetup = oFileDlg.GetPathName();.
m_install is a Cstring variable of another class.Now i hav e defined a cString variable in the same class.
|
|
|
|
|
<br />
CString str;<br />
<br />
static TCHAR BASED_CODE szFilter[] = "Windows Setup file (*.pdf;*.xml)|*.pdf;*.xml||";<br />
<br />
CFileDialog oFileDlg(TRUE,"pdf","",OFN_FILEMUSTEXIST|OFN_NOCHANGEDIR, szFilter);<br />
oFileDlg.m_ofn.lpstrTitle = "Select the Installable Application";<br />
<br />
if(oFileDlg.DoModal() == IDOK)<br />
{<br />
str = oFileDlg.GetPathName();<br />
AfxMessageBox(str);<br />
}<br />
Do you get the path displayed properly? Does the window crash after that?
|
|
|
|
|
Now I remember, I already answered you previously. I asked you to use your debugger to provide us more information. Did you follow that advice ? Where does the code crash exactly ? What is the value returned by GetDlgItem, are you sure you don't access an NULL pointer ?
Man, I won't say it enough time: you have to learn how to use your debugger !It doesn't take a lot of time to understand how it work (for basic debugging), but this will save you hours of time (your problem could already been solved now).
|
|
|
|
|
The only answer we can give you is that you did something wrong in your program. This can happens for a million of different reasons, so without more information, you'll not get a lot of answers.
First of all: a thing that you REALLY need to do is to learn to use your debugger. You cannot imagine how faster it is to solve a problem than posting a message on a forum. Press F5 to start your debugger, this will allow you to narrow the problem a little bit more. Then, you can set breakpoints in your program with F9 and check the value of your variables.
I cannot imagine developping programs without using a debugger, it's like repairing your car without using any tools
|
|
|
|
|
The application is working in my system.But when i run it on the other system it is not coming.I have debugged the application.The error comes after the line of getting path name.
Thanks.
|
|
|
|
|
It seems this code it good maybe your problem after IDOK did you use of debugger
|
|
|
|