|
You need to look at the CreateFile Api. Serial Reading and writing on windows is done the same way file writing is done.
Best Of Luck
Forever Developing
|
|
|
|
|
Search for CSerialPort Class IN CP,that will solve your problem
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
hi all,
I am using Visual C++,MFC for My Project. I added a Combo Box to the Dialog.Now I want to add Integer typed variable to the ComboBox.But In the ClassWizard ,"Add Member Variable" Dialog Box, There is no room for integer type.So can't we add integer type as Member variable using class wizard to ComboBoxes?.If possible ,How do I do that ?
expect a answer...
thanks..
|
|
|
|
|
1.first you make member variabel as a string,
such as : m_strTest.
you add using class wizard.
2.then you add data for the ComboBox
3.if you want to get data from combo box, follow this code :
int intData;
switch(atoi(m_strTest))
{
case data you insert1:
intData= 1;
break;
case data you insert2:
intData= 2;
break;
}
UpdateData(FALSE);
|
|
|
|
|
yes .that is right. I mean that,Is there direct way to add integer type Variables to ComboBoxes..
I saw in some programs ,they directly use integer type like this:
void network::DoDataExchange(CDataExchange* pDX)
{CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(network)
DDX_CBIndex(pDX, IDC_COMBO1, m_Band);
//}}AFX_DATA_MAP
}
m_Band is a integer variable.
So there must be a direct way to add integer type variable for a comboBox using Wizard.
if any one know that,send me a reply....
thanks..
|
|
|
|
|
pubududilena wrote:
Is there direct way to add integer type Variables to ComboBoxes
Yes.
for (int nIndex = 0; nIndex < 10; nIndex++)
{
CString strIndex;
strIndex.Format("%d", nIndex);
m_combobox.AddString(strIndex);
}
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
hello guys....
i want to execute device manager using WinExec in MFC Vis C++
The File name is devmgmt.msc
when i execute using run in windows, it can run.
But when i used it using mfc, it can't run
can somebody help me ?
The Code I wrote :
WinExec("C:\Winnt\system32\devmgmt.msc",SW_SHOW);
|
|
|
|
|
ShellExecute() won't work?
[insert witty comment here]
bdiamond
|
|
|
|
|
using WinExec you should call "C:\WINNT\system32\mmc.exe C:\WINNT\system32\devmgmt.msc".
Don't try it, just do it!
|
|
|
|
|
ShellExecute(NULL,"open","devmgmt.msc",NULL,NULL,SW_SHOW);
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
hello everybody,
I need to write kind of scheduler. It will trigger an event every day at 00:00,
00:30, 08:00, 08:30, 16:00 and 16:30.
Can anybody show me a way how to do it in MFC?
Thanks,
Muharrem
|
|
|
|
|
MFC or not, using the ITaskScheduler and ITask interfaces is the easiest way.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I have an app that uses a dll. I will be launching two copies of this app simultaneously. This app uses a dll (no mfc in it). I had made this a win32 dll and didnt see anything about linking options. The way I use this dll is through including the h file, putting the dll in the exe folder and linking in the .lib file through project settings. However I think I am having trouble because I want each copy of the exe to have its own copy of the dll (there are static variables in the dll), and I suspect that its actually being shared and I have only one copy being used by both exes . How do I arange things so that each exe can have its own copy of the dll? My dll functions look like:
Q20_API int Ainit(init_params * params);
This name was generated by the appwizard when i made the win32 dll project.
Thanks,
sb
|
|
|
|
|
Hello,
I have a view. On my view I attached a dialog which has a menu. When I click on view, the dialog appears to be grayed, but when clicked on dialog it appears to be enabled. The same is the case with view, it appears to be grayed when clicked on dialog. Is there any way to make the dialog appear as enabled always irrespective of the focus on it?
can anyone please help me to solve this?
Thanks
Madhavi
|
|
|
|
|
Hello,
I would like to know from where I can download the header file "Wbemidl.h". I have tried, but could not find anywhere. Can anyone help me on the same?
Regards,
Mythri
|
|
|
|
|
It's included with the Windows SDK.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi
I suppose, you must install microsoft sdk for this. I can find this file on my ../microsoft sdk/include folder
Regards
Shiraz
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Hello,
Can you send across that header file as an attachment to me?
Thanks and Regards,
Mythri
|
|
|
|
|
Woah, you need to change your thinking! NEVER download a header file. Headerfiles are always invluded in some package, and must be used with the package. It isn't unheard of for two headerfiles that appear the same on the surface to be differint in subtile ways.
Perhaps the header you are talking about is one you can get from anywhere, but how do you know. You should have asked what package included Wbemidl.h, and where do I get it. You should also include some background on what you are using it with, just in case two different packages have a header with the same name.
Perhaps that is what you ment, but it isn't what you asked!
|
|
|
|
|
I have this code:
static IDirectDrawSurface * CreateOffScreenSurface(IDirectDraw *pdd, int dx, int dy)
{
DDSURFACEDESC ddsd;
IDirectDrawSurface *pdds;
//
// create a DirectDrawSurface for this bitmap
//
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT |DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = dx;
ddsd.dwHeight = dy;
if(pdd->CreateSurface(&ddsd,&pdds,NULL)!=DD_OK)
I get an error :
error C2039: 'CreateSurface' : is not a member of 'IDirectDraw'
c:\program files\microsoft visual studio\vc98\include\ddraw.h(491) : see declaration of 'IDirectDraw'
And I cannot understand why I am getting this error, I have linked the project with ddraw.lib and included the ddraw.h.
when I click at the error line : see declaration of IDirectDraw it shows that CreateSurface is a member function, but why doesn´t the compiler think so???
And when I print pdd->.... it shows a list of the memberfunctions and CreateSurface is listed, so I just can´t see why I have this strange error.
I have the same error with the IDirectDrawSurface memberfunctions.
Does anyone have a clue? I am totally lost.... Thanks for your help, regards Dani
|
|
|
|
|
1. DirectDraw if out-of-date.
2. Maybe your header file is too old (use directx sdk files)
Don't try it, just do it!
|
|
|
|
|
I tried to change the link path to c:\dxsdk\include\, but the problem still exists, when I click on the error it opens the ddraw.h and show this:
/*
* IDirectDraw
*/
#if defined( _WIN32 ) && !defined( _NO_COM )
#undef INTERFACE
#define INTERFACE IDirectDraw
DECLARE_INTERFACE_( IDirectDraw, IUnknown )
{
/*** IUnknown methods ***/
STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
/*** IDirectDraw methods ***/
STDMETHOD(Compact)(THIS) PURE;
STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE;
STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE;
STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC, LPDIRECTDRAWSURFACE FAR *, IUnknown FAR *) PURE;
Can there be another problem?
Please help, cheers Dani
|
|
|
|
|
Hi All,
I am trying to disable the minimize & maximize button in a dialog based application. The close button get's disable, but the other two are not disabled. The code i am using is
CMenu* pSM = GetSystemMenu(FALSE);
if(pSM)
{
pSM->EnableMenuItem(SC_CLOSE, MF_GRAYED |MF_BYCOMMAND|MF_DISABLED);
pSM->EnableMenuItem(SC_MAXIMIZE, MF_GRAYED |MF_BYCOMMAND|MF_DISABLED);
pSM->EnableMenuItem(SC_MINIMIZE, MF_GRAYED |MF_BYCOMMAND|MF_DISABLED);
}
i am adding this code on OnInitDialog.
Thanx in Advance
Sujan
|
|
|
|
|
Can you not just remove the WS_MINIMIZEBOX and WS_MAXIMIZEBOX styles from the dialog template?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I have a list control in report view mode.
I'm trying to highlight rows based on what info they have.
Highlighted ones have the text color set to red, non-highlighted gets black.
What I have (pseudocode) is this:
<br />
for (int i = 0; i<numEntries; i++) {<br />
color = function_to_check_info_and_return_COLORREF(info);<br />
myList.SetTextColor(color);<br />
myList.InsertItem(etc);<br />
myList.SetItemText(blah, 1, value);<br />
.<br />
.<br />
.<br />
myList.SetItemText(blah, 5, value);<br />
}<br />
Assume my function to get the COLORREF works as planned (it does, it's been checked by 2 other software engineers. They have no idea why this won't work either).
Would you agree that bit of code should set the text color for each row in the report based on the return value of the COLORREF function?
Well, it doesn't.
What actually happens is that all the items are added to the list, and then MFC applies the last returned COLORREF to all items in the list. What?!
I had the app open on one monitor while stepping through it on the other, and the list control only shows the items once they've all been added.
HOWEVER, the scrollbar appears and resizes as each item is added. So while the list is populating, the scrollbar reflects what should be in it, but it has no contents. Bizzare.
To try and force it to update as it should, I added:
<br />
myList.SetRedraw(TRUE);<br />
myList.Invalidate(TRUE);<br />
Here is a direct quote from MSDN as to what SetRedraw does:
Updating a control or window with large amounts of data may cause flicker. In such cases it may be better to turn off drawing. While the redraw flag is cleared, the contents will not be updated after each change and will not be repainted until the redraw flag is set.
In other words, setting the redraw flag to true should mean the list control updates each time something is inserted. Not so. It appears both of those statements are simply ignored.
Only once have I been able to get it to do what I want, under very specific conditions. If:
* I call myList.SetColumnWidth(someCol, LVSCW_AUTOSIZE);
and
* The data width in someCol requires the column to be resized
THEN it will work.
Obviously this is useless, as it requires each entry in someCol to be longer than the last in order to get the desired effect.
Just to prove to myself I wasn't going mad and that you CAN use settextcolor for individual entries in the list, I added a button which, when clicked, inserts an item into the list in green. It works fine (and the rest of the list stays in the color it was).
So, in conclusion:
What's going on? Am I trying to make it do something it can't or what?
I have spent all morning looking at this thing, tracing, stepping, setting breakpoints, setting watch variables, and its ABSOLUTELY FINE in terms of program flow.
Everything gets set when it should be set.
Everything is called in the correct order.
Either I've misunderstoon the purpose/functionality of settextcolor or MFC has decided to set the color when it feels like it, not when I ask it to.
If anyone has any ideas I'll be very grateful!
|
|
|
|
|