|
Why not use the ReadFile function instead?
BOOL ReadFile(
HANDLE hFile,
LPVOID lpBuffer,
DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead,
LPOVERLAPPED lpOverlapped
);
I.E.
HANDLE hFile;
char buffer[BUFSIZE];
DWORD dwBytesWritten;
BOOL fSuccess;
hFile = CreateFile(TEXT("C:\\test.txt"),
GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
fSuccess = ReadFile(hFile,
buffer,
strlen(buffer)+1,
&dwBytesWritten,
NULL);
http://msdn2.microsoft.com/en-us/library/aa365467.aspx[^]
When you have all the data in the lpBuffer you can add it to each structure variable.
This is just a suggestion ....
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Programm3r wrote: hFile = CreateFile(TEXT("C:\\test.txt"),
Does this not produce an error for you?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Heh! Leave it to Microsoft to have an API called ReadFile that reads from a file opened for
writing.
Oh wait...maybe that was a typo
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
I did some coding in VC++ to detect a device connected to the PC.
I used the sample coding from this siteitself...
LRESULT CHWDetectDlg::OnMyDeviceChange(WPARAM wParam, LPARAM lParam)
{
....
....
if ( DBT_DEVICEARRIVAL == wParam || DBT_DEVICEREMOVECOMPLETE == wParam ) {
PDEV_BROADCAST_HDR pHdr = (PDEV_BROADCAST_HDR)lParam;
switch( pHdr->dbch_devicetype ) {
case DBT_DEVTYP_DEVICEINTERFACE:
PDEV_BROADCAST_DEVICEINTERFACE pDevInf = (PDEV_BROADCAST_DEVICEINTERFACE)pHdr;
UpdateDevice(pDevInf, wParam);
break;
....
....
}
Here in this code wParam should contain either DBT_DEVICEARRIVAL or
DBT_DEVICEREMOVECOMPLETE ...
But it contains DBT_DEVNODES_CHANGED i.e it is detecting there is some device node changes when any device is inserted or removed..
But i want to know whether it is inserted or removed so that it will go into theloop in the above code...
How to proceed...
Waiting for suggestions..
Regards
vijay
|
|
|
|
|
Hi all,
I Want to Know About
1) Why can't we directly instantiate an Abstract Class, and why we have to create it by its Derived Class only.
2) What is the Difference between an Abstract Class and an Interface in COM.
Please give your suggestions.
Uday kiran
|
|
|
|
|
uday kiran janaswamy wrote: 1) Why can't we directly instantiate an Abstract Class, and why we have to create it by its Derived Class only.
Because that's one of the C++ feature (and it is a very valuable feature: it prevents user to instantiate classes that are not supposed to be instancied). By supplying at least one pure virtual function, your class is abstract:
CMyClass
{
virtual void MyFunc() = 0;
};
uday kiran janaswamy wrote: 2) What is the Difference between an Abstract Class and an Interface in COM.
For me (but I don't know if this is totally true), an abstract class is a class that cannot be instantiated directly (meaning it has at least one pure virtual function). A interface is a "pure abstract class": a class that has only member functions (no member variables) and all of them are pure virtual. In fact this class has no functionality at all, it is just an interface to a class that implements those functionalities.
|
|
|
|
|
Thanks Cedric Moonen you have given a most valuable information about Abstract Class and an Interface.
Uday kiran
|
|
|
|
|
uday kiran janaswamy wrote: 1) Why can't we directly instantiate an Abstract Class, and why we have to create it by its Derived Class only.
Because, its not complete on its own.
uday kiran janaswamy wrote: 2) What is the Difference between an Abstract Class and an Interface in COM.
To add to Cedric, abstract class can have some functions with definitions. But that could not be case with interface, It will have only pure virtual fucntions.
To stick to this, later VS compiler provide keyword __interface .
|
|
|
|
|
prasad_som wrote: To add to Cedric, abstract class can have some functions with definitions.
Well, it was implicitely stated: the only restriction of an abstract class is that it cannot be instanciated (so at least one pure virtual function). Now, you can have whatever you want in the class (even member variables).
|
|
|
|
|
Cedric Moonen wrote: Well, it was implicitely stated
I mentioned this to differentiate it from interface . And should be.
|
|
|
|
|
uday kiran janaswamy wrote: What is the Difference between an Abstract Class and an Interface in COM.
a COM interface has more constraints (or features) than an C++ abstract class, i.e. a COM interface is an abstract class:
(1) having only methods.
(2) having a unique global identifier.
(3) exposing, at least, the methods of the IUnknown interface (QueryInterface , AddRef , Release ).
hope that helps
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
hi
i am satheesh .
i am Begnier for vc++ programming .
so i need help for develope my knowlege.
currently i am developing one project in PROE CAD came model using vc++.
vc++ using preprosser. so i need some help for all
MY qustione
1.How to creat DLL Library in vc++ .
2.how to convert DLL File to .exe file.
|
|
|
|
|
Satheeshkumar_Balakrishnan wrote: How to creat DLL Library in vc++ .
Depends of your IDE but in general you can choose that when you create your project.
Satheeshkumar_Balakrishnan wrote: how to convert DLL File to .exe file.
You can't directly. You need to create a new project and the files you want to add in your exe. You cannot convert a DLL into a exe, these are two totally different things.
Satheeshkumar_Balakrishnan wrote: vc++ using preprosser
What's a preprosser ?
|
|
|
|
|
I think he meant pre-processor??
John P.
|
|
|
|
|
That's what I first guessed but then his sentence doesn't make any sense...
|
|
|
|
|
For first your question codeproject has a lot of articles about create dll.Articles on DLLs[^]
For second question what does mean convert dll to exe
|
|
|
|
|
Hi All,
I have created a MDI application. I open two child windows in the MDI (by clicking File-> New).
I will draw a rectangle in one child window.
I need to drag the rectangle from one child window and drop into another.
Any solutions or ideas???
Thank You.
|
|
|
|
|
You requirement seems to be weired. There is know way a rectangle drawn can be candidate for drag and drop operation.
|
|
|
|
|
Then your application should be both an ole server and a client.
MFC has a greate support for that. See COleDropTarget, COleDropSource documentation.
--
======
Arman
|
|
|
|
|
Just a drawn rectangle needs to be dragged?
Which part is giving you trouble - drawing the rectangle, notifying the receiving window of the
drop, dragging in general, something else?
Mark
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
Notifying the receiving window of the
drop..
|
|
|
|
|
I need to draw some Unicode text with ScriptString API inside a dialog box.
I tried using these functions inside dialog procedure's WM_INITDIALOG:
WCHAR g_szCurrentString[30] =
{
'H', 'e', 'l', 'l', 'o',
0x064a, 0x064f, 0x0633, 0x0627, 0x0648, 0x0650, 0x064a,
'W', 'o', 'r', 'l', 'd',
0
};
SCRIPT_STRING_ANALYSIS GetStringAnalysis(HDC hdc, WCHAR *wstr, UINT wlen)
{
SCRIPT_CONTROL scriptControl = { 0 };
SCRIPT_STATE scriptState = { 0 };
SCRIPT_STRING_ANALYSIS scriptStringAnalysis;
ScriptStringAnalyse(
hdc,
wstr,
wlen,
wlen * 2,
-1,
SSA_GLYPHS|SSA_FALLBACK,
0,
&scriptControl,
&scriptState,
0,
0,
0,
&scriptStringAnalysis
);
return scriptStringAnalysis;
}
void Uniscribe_TextOut(HDC hdc, int xpos, int ypos, int selstart, int selend)
{
SCRIPT_STRING_ANALYSIS ssa = GetStringAnalysis(hdc, g_szCurrentString, lstrlen(g_szCurrentString));
if(selend < selstart)
{
int t = selstart;
selstart = selend;
selend = t;
}
ScriptStringOut(
ssa,
xpos,
ypos,
0,
NULL,
selstart,
selend,
FALSE
);
ScriptStringFree(&ssa);
}
void PaintWnd(HWND hWnd)
{
PAINTSTRUCT ps;
RECT rect;
HDC hdcMem;
HBITMAP hbmMem;
BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rect);
hdcMem = CreateCompatibleDC(ps.hdc);
hbmMem = CreateCompatibleBitmap(ps.hdc, rect.right, rect.bottom);
SelectObject(hdcMem, hbmMem);
FillRect(hdcMem, &rect, GetSysColorBrush(COLOR_WINDOW));
Uniscribe_TextOut(hdcMem, XBORDER, YBORDER, nSelStart, nSelEnd);
BitBlt(ps.hdc, 0, 0, rect.right,rect.bottom, hdcMem, 0, 0, SRCCOPY);
DeleteObject(hbmMem);
DeleteDC(hdcMem);
EndPaint(hWnd, &ps);
}
Code is btw from http://www.catch22.net/tuts/zips/scriptstring.zip/
It works fine in main window (WM_PAINT), but something is wrong with dialogs. I tried replacing ps.hdc with GetDC(dialogHwnd) too. Should I draw inside an owner-drawn element?
Thanks.
-- modified at 7:33 Thursday 22nd February, 2007
|
|
|
|
|
Why you are writing it in WM_INITDIALOG ?
Shouldn't this be written in WM_PAINT ?
|
|
|
|
|
Good point. I had tried it before but accidentally placed case WM_PAINT inside WM_COMMAND swtich thinking it does not work. Luckily I noticed this stupid error now.
Thanks, it works!
|
|
|
|
|
jones166 wrote: thinking it does not work.
Need to look in to code for sure, if such obvious message handlers are not getting called.
|
|
|
|
|