|
i wish i can send you a book through the net but it is still impossible if it is in phisical paper format ... I strongly recommend you ( if you find it ) "Advanced Programming on windows" by Jeffrey Richter.
However if you arent such an adventure man and simply want to solve the problem by now, you have to find in the msdn the documentation about: CreateFile, WriteFile and ReadFile, and SetCommConfig. They are functions of windows api. Do not forget to include <windows.h>. With those four functions and a lot of error discovering efforts you will probably success in comunicating with serial port. I have done it before in my work but i dont have the code.
|
|
|
|
|
Hi,
I am developing an application where I open COM2 port for communication.The code to open the port is
HANDLE hTest;
hTest = CreateFile ("COM2",GENERIC_READ | GENERIC_WRITE , 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
if ((hTest == NULL) || (hTest == INVALID_HANDLE_VALUE))
MessageBox ("Port cannot be opened",NULL,MB_OK);
else
MessageBox ("Port cannot be opened",NULL,MB_OK);
This code is running fine when I run the code on Windows 98 or windows 2000 but when I try to run it on Windows XP, the CreateFile statement returns 0xffffff which is INVALID_HANDLE_VALUE.
Can any one tell how can i open a port on Windows XP
Rits
|
|
|
|
|
See if COM2 is in the System->Device Manager. I believe I had problems opening port4 because it wasn't listed, so I had to install some drivers.
Otherwise, no idea.
|
|
|
|
|
Also make sure nothing else is using the port. For example, a printer driver configured to use com2 could cause the create file call to fail. You should use GetLastError() for more detailed error returns.
|
|
|
|
|
Hi Paul,
You are Right.
Some other application was openiing the port and the port was not being closed.
When i close the port first, it works fine
Rits
|
|
|
|
|
How can i mix audio and video using DirectX
thanx
|
|
|
|
|
Hi programmers,
How can I rename an existing VC++ project?
|
|
|
|
|
Hi,
Think it is difficult !
Sujan
|
|
|
|
|
|
Thanks for your response.
It will be very helpfull.
|
|
|
|
|
Can you show me how to access controls of Dialog Template using in CDialogBar Class from View class(My Application is MDI). I want to change content of the control when View's modified.
Thanks a lot,
|
|
|
|
|
I have implemented drag and drop on my new aplication and i have a strange error.
In InitInstance method of app object i call AfxInitOle() function.
Lets we call source window A and target window B.
In A´s OnCreate message handler i use the following code:
medium.tymed = TYMED_FILE;
medium.lpszFileName = (unsigned short *)((LPCSTR)(new CString("TempDragDrop.dat")));
source->CacheData(((CLightControllerApp *)AfxGetApp())->ID_FOCUS_FORMAT,&medium);
In B´s OnCreate message handler i use the following code:
target.Register(this);
And on OnDestroy message handler of B window I use:
target.Revoke();
I have no idea of what is going wrong, so please help me. Many thanks to all you and sorry for my poor english.
|
|
|
|
|
i have found it, and i wish i can help anyone who finds the same problem... The cuestion is that when you call the CacheData function, you must care every value in the STGMEDIUM and FORMATETC structures. A good idea is to make something like this: ZeroMemory(pMedium, sizeof(STGMEDIUM )) and ZeroMemory(pFormatetc, sizeof(FORMATETC )) before beginning to give values to its members. You must remember too that since these two structures are passed to CacheData() they arent owned by aplication, that means for example that you can do something like this:
pMedium = new STGMEDIUM;
...;
...->CacheData(...,pMedium, ...);
...;
delete pMedium;
because this will surely cause a program´s crash.
|
|
|
|
|
i have found it, and i wish i can help anyone who finds the same problem... The cuestion is that when you call the CacheData function, you must care every value in the STGMEDIUM and FORMATETC structures. A good idea is to make something like this: ZeroMemory(pMedium, sizeof(STGMEDIUM )) and ZeroMemory(pFormatetc, sizeof(FORMATETC )) before beginning to give values to its members. You must remember too that since these two structures are passed to CacheData() they arent owned by aplication, that means for example that you can do something like this:
pMedium = new STGMEDIUM;
...;
...->CacheData(...,pMedium, ...);
...;
delete pMedium;
because this will surely cause a program´s crash.
|
|
|
|
|
I have made a sdi application in MFC.
I added a menu item, and a routine when it is clicked. That routine creates an instance of, and displays, an information dialog I created.
What I need to do though is display some information in that dialog from the loaded in document.
The biggest problem I always seem to have is finding out how to access the document in another class like my dialog class.
So I am wondering what I need to do to get a document pointer to my dialog class. Either by passing it in from MainFrm when I create the dialog, or better yet, have my dialog class itself get a pointer to the document.
Anyone have any ideas or code samples?
I notice my view class has something like:
CDXtoXDDoc* CDXtoXDView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDXtoXDDoc)));
return (CDXtoXDDoc*)m_pDocument;
}
|
|
|
|
|
yes, i supose that you have defined the message handler of this menu item in the view class. I supose too that you call de DoModal() function of the dialog class in this message handler. Therefore your´s dialog parent window is the view window. If you call the dialogs method:
CWnd * GetParentWnd() and cast teh result to a (CDXtoXDView *). Just doing this: (CDXtoXDView *)GetParentWnd(), then you have a pointer to the view object. You just have to call GetDocument() view´s method to obtain the document pointer. This should work.;)
|
|
|
|
|
I'll give the suggestions a try. Thank you.
When I use the classwizard to create the onclick event, it put it in MainFrame:
void CMainFrame::OnToolsShpproperties()
{
CDLGShpFileBreakdown dlgSHPBreakdown;
dlgSHPBreakdown.DoModal();
}
Your code will still work?
|
|
|
|
|
no, it won´t work for sure. All is about getting the current view when creating the dialog. If you have the view, you have the doc with GetDocument(). From the dialog, you can get a pointer to the main frame with the method: GetParentFrame( ). Once you have the pointer to the frame, you can call its GetActiveView() method to get the current view. Thats all, i hope i have been usefull to you.
|
|
|
|
|
It's fine. I figured it out. In the past when I have added a command handler for a menu item, I have always just used the default in the drop down which is mainfrm. I removed that one, and selected my dialog in the list this time. It put the menu command handler in my document class this time, and all the data I want to display is in that class, so easy solution.
Thanks for all the help.
|
|
|
|
|
If the menu's handler function is in the view, try:
CDXtoXDView::OnMenuItem()
{
CDXtoXDDoc *pDoc = GetDocument();
CMyDialog dlg(pDoc->somedata);
dlg.DoModal();
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
hi there.
Yesterday i've got a problem with CButton and icons,
so i looked here in codeproject for a better Button class.
i found many great buttons here but the overview is really bad.
is there any button collection - or an ultimative button ?
i think many people got that - so , how you've solved that problem ?
greetings from austria - Tom
|
|
|
|
|
take the ones with the highest rating.
depending one what are your requirements for your buttons, it might be hard for me/us to tell you which one is the best.
Have you tried some of them ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
yes i tried a few.
i hoped that peopled made a "All Buttons you need"-set.
at the moment i am planning to improve a nice button with the features of other buttons - make it easy to use and so on - if the authors let me.
what do you think about it ?
just RAM-wasting or a good tool if good implemented ?
greets
|
|
|
|
|
Here is one.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
thx for the tipp.
look here (better Bitmap Button) its a improved Button as the one you have shown me ( i think) originaly by Joseph M. Newcomer, modificated by Jeff Mallett.
i saw your CRegionButton too, and a few others too.
any suggestions what buttons i should use ?
i am looking for a nice button suite or a all in one button, so i dont waste time for learning the wrong buttons.
greetz
|
|
|
|