|
kitty5 wrote: Is (buff + offset) the proper syntax to increment the address of buff?
Yes, that's how you need to do it. And your code snippet is correct also. You can stop the loop when offset == the number of bytes you need to read.
|
|
|
|
|
Thank you so much for helping me clear this all up!
Things are so much clearer after a couple cups of coffee ....
Kitty5
|
|
|
|
|
1) it will overwrite. To append, use lpNumberOfBytesRead to offset the buffer pointer in subsequent calls to ReadFile.
2) Yes. lpBuffer is a void pointer, so it will be handled as an array of bytes. If the endian-ness of the words you read is correct you will get an array of 256 ULONGS when you read 1024 bytes.
3) It will read exactly nNumberOfBytesToRead. ReadFile will wait until it has read these bytes (assuming you don't use overlapped I/O, but that's another story), but it will not read more than this number of bytes (this would also wrech havoc on your buffer)
Cheers
Steen.
"Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006
|
|
|
|
|
Steen Krogsgaard wrote: ReadFile will wait until it has read these bytes (assuming you don't use overlapped I/O, but that's another story),
Not necessarily. For example, using a serial port you can configure it with some specific timeouts and it often happens that the read function will time out before having read all the data. But of course, you can configure it with an infinite timeout also (and in that case, it will follow what you described).
|
|
|
|
|
Right. In any case, it won't read more than the number of bytes specified.
Will ReadFile return true if there is a timeout?
Cheers
Steen.
"Are you gonna check your makeup when you're done whining?" John Simmons, 05/31/2006
|
|
|
|
|
Steen Krogsgaard wrote: Will ReadFile return true if there is a timeout?
Yes, it returns true only if an error occurs. A timeout in that case is not an error.
|
|
|
|
|
kitty5 wrote: buff = new ULONG[11250000]; //total of 11,250,000 32-bit words
Just an FYI: Avoid declaring such large chucks of memory (be it stack or heap). While this array alone (which will be about 45 MB) won't cripple your system, imagine declaring 10 or 20 of them (throughout your application). Next thing you know, your application requires a full GB of RAM by itself (not good!). If possible, you should try to read a large file in smaller chunks, process the data, and read the next chuck.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Dear all,
I am very new in visual C++. I currently use the Visual C++ version 6.0. The problem I am faced on is relative the list controls.
I have a list control in report format with a grid. In that control I load data from an database. I would like to print some items in bold and at the same time I would like to change the text color and the background color of specific item. I saw for the fonts exists a function but I do not understand how to use it. Is it possible to give me an example of how I could do that?
Also I like to achieve some alignments. For example the first column has title “stock descriptions” I would like the next items aligned be based on that. Also I would like if it is possible define some as base and all below became one or more tabs right. Is possible to achieve that? (please give some code example for that if are possible).
Thanks in advance for your time.
Best regards,
Konstantinos.
|
|
|
|
|
|
Dear Sir,
I do not know why but my control does not have the properties that in sample program displayed.
Any ideas?
|
|
|
|
|
konstantinos_1000 wrote: control does not have the properties that in sample program displayed
this is because he have created a new class and modified the drawing of Listcontrol inside that class. In your application instead of using CListCtrl as the base class of the List ctrl, Use the class in that application. There will be funtion in that class that fulfill ur requirment.
nave
|
|
|
|
|
Do you need to change color from CListCtrl?
|
|
|
|
|
|
SeeCListCtrl::SetTextBkColor CListCtrl::SetTextColor CListCtrl::SetBkColor
|
|
|
|
|
dear Sir ,
Could you help me with the adjustment of the data.
Example
main title
parameter-1
sub parameter
sub parameter
parameter-2
|
|
|
|
|
|
Sir, Windows allots 4 GB space for Proccess can you tell me how much of that virtual memory is partitioned for the O.S and for our Application?
Fly Like An Eagle With MIGHTY POWER.
|
|
|
|
|
2 Gb for system, 2 Gb for application
unless you have the /3Gb switch enabled in windows
Setting the 3GB switch
Darka [ Xanya]
"When you're taught to love everyone, to love your enemies, then what value does that place on love?"
|
|
|
|
|
How can I use the GetDeviceGammaRamp/ SetDeviceGammaRamp APIs to adjust the gamma for a dual monitor system with the display set to one screen stretched over two monitors? (Each monitor has its own slightly different gamma adjustments.
I've seen these examples:
http://www.codeproject.com/miscctrl/gamma_manager.asp?msg=1598211&mode=all&userid=16251#xx1598211xx
http://www.codeproject.com/csharp/Gammit.asp
but they don't actually address the issue I am unsure of which i guess is how i get a device context for each monitor even though they are being treated as one screen. Is this possible?
Stephen
|
|
|
|
|
Try using the EnumDisplayMonitors and the HDC is returned in the MonitorEnumProc.
Any sufficiently gross incompetence is nearly indistinguishable from malice.
|
|
|
|
|
Gosh, I know this is a dreadful title, and probably a dreadful thread, so please feel free to direct me elsewhere if appropriate.
I'm just thinking about adding some simple (peer to peer?) network functionality that will allow two users to run a dialog application and send small packets of data, perhaps from controls to each others dialog with a view to some very simple gaming/strategy apps.
Is this something that requires a humongous amount of effort, or can it be cobbled together quite quickly. Assume that the user base for this is likely to be no more than 10 people in the whole world, all friends so it can be quite rough and ready!
ideally if there was a way to "sync" the exchange of data such that Dialog A sent some data but Dialog B couldn't see the result until Dialog B itself had sent a corresponding data item, that would be great.
|
|
|
|
|
Hi,
I am printing a piece of text to the printer. By using "GetDeviceCaps", I can get the physical height and width of the paper (PHYSICALHEIGHT and PHYSICALWIDTH). I can also get the left and top margins to the printable area (PHYSICALOFFSETX and PHYSICALOFFSETY), but how do I know the bottom and right margins? (or the width and height of the printable area) I can of course assume a safe margin (like an inch or so), but this would only be a gueass. It does seem strange that the printer can give information about the top and left "non-printable area" size, but says nothing about bottom or right. Does anyone have an idea?
Thanks in advance.
William
|
|
|
|
|
Hi all,
i am creating a Cirlcle with
CDC::Ellipse(...).
In the View the Circle is Created in MouseDown(...),MouseUp(..) and MouseMove(...) Functions,
But i want to Drag that Circle what i have created when the mouse is in between the Circle.
Please give me a Solution.
uday.
|
|
|
|
|
Hi,
What you do is that you create a compatible device context (CreateComaptibleDC), and you create a bitmap, the size of your original bitmap (CreateCompatibleBitmap). You select this bitmap into your compatible DC.
Now, you have an area in which you can save your original background.
First, you copy the information on the screen (from the original device context) into your compatible device context, using BitBlt.
Then you draw your circle. When you act on a mouse-move event, you restore the original background again (using BitBlt, copying from your compatible DC to your original DC) and then you re-draw the circle on its new location.
If you need some more info on the subject, I could probably cut and paste some sample code from an existing project.
Have fun!
William.
|
|
|
|
|
Hi Edinburg,
Please help me out. I am sending the code what i have written to draw the Circle.
//========================================================================
void CPaintingView::OnLButtonDown(UINT nFlags, CPoint point)
{
Anchor.x = point.x;
Anchor.y = point.y;
OldPoint.x = Anchor.x;
OldPoint.y = Anchor.y;
CScrollView::OnLButtonDown(nFlags, point);
}
void CPaintingView::OnLButtonUp(UINT nFlags, CPoint point)
{
DrawTo.x = point.x;
DrawTo.y = point.y;
CClientDC dc(this);
if(bEllipseFlag)
{
SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR1));
dc.SelectStockObject(NULL_BRUSH);
dc.Ellipse(Anchor.x, Anchor.y, DrawTo.x, DrawTo.y);
}
CScrollView::OnLButtonUp(nFlags, point);
}
void CPaintingView::OnMouseMove(UINT nFlags, CPoint point)
{
int nOldMode;
CClientDC* pDC = new CClientDC(this);
if((nFlags && MK_LBUTTON) && bEllipseFlag)
{
SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR1));
nOldMode = pDC->GetROP2();
pDC->SetROP2(R2_NOT);
pDC->SelectStockObject(NULL_BRUSH);
pDC->Ellipse(OldPoint.x, OldPoint.y, Anchor.x, Anchor.y);
pDC->Ellipse(Anchor.x, Anchor.y, point.x, point.y);
OldPoint.x = point.x;
OldPoint.y = point.y;
pDC->SetROP2(nOldMode);
szPosx.Format("%d",point.x);
szPosy.Format("%d",point.y);
Res = "x=";
Res += szPosx;
Res += ",";
Res += "y=";
Res += szPosy;
CMainFrame* pFrameParent = (CMainFrame *)GetParentFrame();
pFrameParent->m_wndStatusBar.SetPaneText(4,Res);
}
delete pDC;
CScrollView::OnMouseMove(nFlags, point);
}
void CPaintingView::OnLButtonDblClk(UINT nFlags, CPoint point)
{
if(bEllipseFlag == true)
{
CRect rect;
ClientToScreen(&rect);
GetClientRect(&rect);
InvalidateRect(rect,TRUE);
}
CScrollView::OnLButtonDblClk(nFlags, point);
}
//===========================================================================
Please help me out.
uday
|
|
|
|