|
Sounds like you need to read a chapter on serialization. Go through MSDN's Scribble tutorial.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
How To Copy the Desktop image to BMP file???
I'd appreshiate any help and especially for the clear WinAPI code without using any classes.
|
|
|
|
|
GetScreenDC, CreateCompatibleDC, CreateDIBSection, [edit] SelectObject the DIB into the compatible DC [/edit], BitBlt from the screen DC to your compatible DC, then work out how to fill in the BITMAPFILEHEADER and BITMAPINFOHEADER structures.
See Charles Petzold's Programming Windows, Fifth Edition for information on working with bitmaps.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
I stell can't understand some moments.
I do this and get nothing, What am i doing wrong?:
char* data = new char[GetSystemMetrics(SM_CXSCREEN)*GetSystemMetrics(SM_CYSCREEN)*3];
BITMAPINFO BitmapInfo;
BITMAPFILEHEADER BFH;
memset(&BFH,0,sizeof(BITMAPFILEHEADER));
BFH.bfType = 'MB';
BFH.bfSize = sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+GetSystemMetrics(SM_CXSCREEN)*GetSystemMetrics(SM_CYSCREEN)*3;
BFH.bfOffBits = sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
BITMAPINFOHEADER bitmapinfoheader;
bitmapinfoheader.biSize = sizeof(BITMAPINFOHEADER);
bitmapinfoheader.biWidth = GetSystemMetrics(SM_CXSCREEN);
bitmapinfoheader.biHeight = GetSystemMetrics(SM_CYSCREEN);
bitmapinfoheader.biPlanes = bitmapinfoheader.biBitCount = 24;
bitmapinfoheader.biCompression = 0;
bitmapinfoheader.biSizeImage = GetSystemMetrics(SM_CXSCREEN)*GetSystemMetrics(SM_CYSCREEN)*3;
bitmapinfoheader.biXPelsPerMeter = bitmapinfoheader.biYPelsPerMeter = bitmapinfoheader.biClrUsed =bitmapinfoheader.biClrImportant = 0;
HDC hDC = ::GetDC(NULL);
HDC hCompatibleDC = ::CreateCompatibleDC(hDC);
HBITMAP hBitmap =::CreateDIBSection(hCompatibleDC,&BitmapInfo,DIB_RGB_COLORS,(void**)data,NULL,NULL);
BitBlt(hDC,0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN),hCompatibleDC,0,0,SRCCOPY);
CFile file;
file.Open("New.bmp",CFile::modeWrite|CFile::modeCreate);
file.Write(&BFH,sizeof(BITMAPFILEHEADER));
file.Write(&bitmapinfoheader,sizeof(BITMAPINFOHEADER));
RGBQUAD rgb;
file.Write(&rgb,sizeof(RGBQUAD));
file.Write(data,GetSystemMetrics(SM_CXSCREEN)*GetSystemMetrics(SM_CYSCREEN)*3);
file.Close();
|
|
|
|
|
Firstly I'd pull out every use of GetSystemMetrics(SM_CXSCREEN) and GSM(SM_CYSCREEN) and store them in variables instead - this will make the code clearer.
The value of a two-character literal is undefined. Set BFH.bfType to 0x4D42.
The documentation for BITMAPINFOHEADER indicates that biPlanes should be set to 1. I think you can get away with setting biClrUsed to zero; if you do this, you should not write any RGBQUAD structures after the BITMAPINFOHEADER.
biCompression should be set to BI_RGB. You should probably set biXPelsPerMeter and biYPelsPerMeter: you can either compute them from GetDeviceCaps( hDC, LOGPIXELSX ) or simply write in the appropriate value for 96dpi: 3780.
A line of a DIB is always an exact multiple of 4 bytes long. If the number of bytes per pixel multiplied by the number of pixels per line is not a multiple of 4, you must round up to the next multiple. This also affects your original block allocation.
I seem to remember that there are also some odd alignment requirements for a BMP file, but I can't remember them off-hand.
If other programs render your bitmap upside down, you may need to set biHeight to a negative value (e.g. -480 for a 480-pixel high image).
If none of this helps, step through the code and see which line fails, and what the Windows error value is.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hi,
I want to draw the great circle of a sphere (radius R, center (0,0,0) ), between 2 given points: P1(x1, y1, z1), P2(x2, y2, z2).
Do you have any general algorithm for that?
Do you know where can I get more information about this subject?
Thank you.
|
|
|
|
|
All information you can find in any book about analytic geometry. Math is fun
Robert-Antonio
"Czech Railways discovered, that in case of disaster the most damaged wagons
were the first and the last. So they decided to create trains without them."
|
|
|
|
|
Can you recomand for a book?
Thanks,
Reli.
|
|
|
|
|
HI ALL,
I have already created directory.I want to monior this directory, for any chages, like file copying , removing. Which method I should use?
VikramS
|
|
|
|
|
For an "easy" approach, try implementing a FileSystemWatcher object from the .Net Framework. This object has capabilities to watch for all events you specified.
Without the .Net Framework, I remember that there was a discussion over this matter earlier on the forums. You could try searching.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
|
In addition to Brian D's suggestion, also check out FindFirstChangeNotification() .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi ALL,
I want to communicate between 2 different machines , for data transfer.Which is the best method using pipes or Sockets?
VikramS
|
|
|
|
|
As far as I know, named pipes are memory sections that allow processes running on the same computer to exchange data between each other. A socket, on the other hand, represents a connection to an external computer.
Because you are running two different machines, I would see the sockets as the only reasonable option.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Nope. Named pipes support communication with other computers too, although it depends on the OS version. I don't think W9x allows you to create a named pipe, so if you have 9x/ME as a taget, you must run with sockets.
Steve S
|
|
|
|
|
Hi, basically sockets is a portable mechanism to comunicate between process and machines boundaries over any platform, if you are programming pipes on windows it will work just on windows based networks (not for internet) and finally pipes programming are easier then sockets programming.
GuimaSun
www.nexsun.com.br
|
|
|
|
|
Is there any performance Issue?
VikramS
|
|
|
|
|
Hi,
my current project consists of a .net application (exe in VB.NET) and a VC++ DLL. Normally, I just call functions in the DLL out of my application, which works just fine. But sometimes I'd like to do it the other way round: to call functions in the .net application out of my C++- Code. Is this possible, and if so, how is it done?
Thanks a lot
mosquitooth
|
|
|
|
|
Hmm..
Considering that you can use the handle of a loaded DLL to get pointers to the exported functions inside, it would seem logical that the same procedure can be applied vice-versa.
When you load an application, you usually get an instance handle. Passing this instance handle out of the application context (thread) into a DLL's handler function (residing in another thread), should allow you to use GetProcAddress or a similar function to get the exported symbols of your .Net application.
This should be pretty easy to implement with MFC, just by using AfxGetInstanceHandle in the executable, and passing this handle over to the DLL, you can use the handle to get the exported symbols. But a case with VB .Net and VC++ DLL, I'm not sure. I don't know how you can export symbols from a VB.Net application/DLL. See the VB manual for instructions on this one.
But the outline of the procedure I mentioned should work. An additional problem may arise because the .Net application most obviously runs over the CLR, and is thus considered 'managed'. Passing a handle of a managed application to an unmanaged DLL might prove "interesting" results
All in all, try this out, and you'll see what happens..
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I have installed Visual C++ 6.0, in Windows XP. Installation gave me some debug symbols for Windows NT, but those are too old to be installed into WinXP.
Does anyone know where to get theese symbols for WinXP ?
It seems that I need it, because when my program crashes, I can't see call stack information
Thanks !
rrrado
|
|
|
|
|
How can I change the title of the PropertyPage in a propertysheet. I mean the name of the tab. I tried with SetWindowText() but it doesn't work.
Thanks
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
Get the tabcontrol of the propertysheet and set the text of the corresponding item whose text you want to change.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
A property sheet, when ran, consists of a property sheet object (the parent), a collection of property page objects (individual dialogs) and a tab control used to switch between the pages. During the first creation stage, the tab texts are taken from the dialog template titles. Changing these pre-build will alter the tab texts.
During run-time, you can change the title by first getting the property sheet object, then asking for the tab control via GetTabCtrl . A CTabCtrl class has a method called SetItem that takes the index of the page and a TCITEM structure.
Assuming in the following example, that m_wndPropertySheet was a pointer to CPropertyPage class, this code fragment will alter the text of the first tab
CTabCtrl* m_ptrTab = m_wndPropertySheet->GetTabCtrl();<DIV>
TCITEM ti;
ti.mask = TCIF_TEXT;
ti.pszText = "New tab text";<DIV>
m_ptrTab->SetItem( 0, &ti ); Hope this will help you out. Naturally, if you are unsure where the correct page is, you can use GetItem ínstead of SetItem to get the item's text and determining the index from there...
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hello everyone:
I have some big size text files, How to insert/delete some content of text file fastly?
Thank you
-Freehawk
|
|
|
|
|
I don't believe that there is some faster way how to insert/delete some data in the middle of the file, than moving data at the end of the file by blocks
(If you need to insert/delete blocks which size is exactly as big as size of allocation unit, you could do this by manipulating FAT/NTFS tables, but this is little but difficult
|
|
|
|
|