|
Actually, C++ is largely a superset of C, so you don't need to specify C/C++ - unless you intend on using one of the exception pieces of C code that don't work in C++, you are using C++ and that is that. Almost every C program is valid C++.
There are a number of options that rapidly slam shut with this line:
>>I don't care to use libraies other than the standard libraies to use C/C++/Win32API/MFC 4.2.
As MFC/Win32 do not come with any compression schemes, you can either renege on your desire not to use a library, or write your own. If you choose the former - check out zLib. If the latter, let us know how it turns out.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
|
|
|
|
|
I'm reading a binary file and at one point there are a couple of bytes (in hex) that contain the number of files in the archive. I put this information into a char array and then print it out as hex. When I display this number using VC++ it is 6670 when it should be 3610. The difference is apprently between using big edian and little edian numbers. The 6670 is big edian. How do I convert?
modified 12-Jul-20 21:01pm.
|
|
|
|
|
The difference is the order in which the bytes are stored. Big endian is MSB (the "big end") first, and little endian is LSB (the "little end") first. So just use the C bitwise operators to reverse the bytes.
WORD w = 0x13A5;
WORD wReversed = ((w & 0xFF) << 8) | ((w & 0xFF00) >> 8);
--Mike--
http://home.inreach.com/mdunn/
#include "buffy_sig"
|
|
|
|
|
When using Win32 function OpenPrinter. I has three parameters. I just wanted to get a printer handle. I tried to open local printer so first parameter and third was set to NULL. The second printer was the printer handle returned. But When I did so, the printer handle is NULL.
Can you tell me to how to get this handle and how to pass the parameter properly?
Thanks
|
|
|
|
|
OpenPrinter(strPrinter, &hPrinter, NULL);
Where strPrinter is the Printer name. This name is the same that you see in the Printer Folder.
In Windows NT/2000 you can set this variable to NULL, this indicates the local printer server.
hPrinter is the HANDLE that returns the function.....
Is Simple. If don't work the problem is with the name of the printer
Cheers!!!
Carlos Antollini.
|
|
|
|
|
You can also create a CPrinterDialog ( or whatever it is called ) and get the PrinterDC from it, if you just want the default printer.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
|
|
|
|
|
Hi there,
simple question:
my programm should perform a last action when windows (2k) is going to shut down.
right now my action is in OnDestroy() and works fine, if the programm closes, but not on shutdown ..
Can you help me ..
thx in advance
bye
murphman
|
|
|
|
|
Have a peek at WM_QUERYENDSESSION (?) message. I think you can perfrom your required actions here.
Chris
|
|
|
|
|
|
Does anyone know I can change the text-color of ONE item in a CListCtrl?
thanks
|
|
|
|
|
That's easy - just handle NM_CUSTOMDRAW notification. Look for "Custom draw (listview)" in your VC++ help index.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Thanks for the tip!
unfortunately I still don't know how to use it in my Dialog based MFC-App
The help did't take me any further.
I want to draw e.g. the first item in red color, the second in green etc..
|
|
|
|
|
Examples are on the CodeProject website - just go to the "List control" section.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
|
Hi,
I like to know how can I get the length(in pixels) between two points.
can i get the length in some other unit too???
Thanks
Ehsan
Ehsan Behboudi
|
|
|
|
|
It's basic trig. If you have a right angle triangle, (a*a) + (b*b) = c*c. C is the side you are dealing with, so if your line is from 0,100 to 100, 47, then a = 100 and b = 100-47, 53. So the square root of (100*100) + (53 * 53) is the length of your line.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
|
|
|
|
|
Hi,
I like to know how can I get the length between two points.
Thanks
Ehsan
Ehsan Behboudi
|
|
|
|
|
Ehsan - is this question related to Visual C++?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hi!
How can I program a function that checks whether the file has been modified? (e.g. changed dialogs etc.)
I have heard something about a CRC-Checksum..how to do that?
thanks in advance
|
|
|
|
|
My code :
CPen penObject;
penObject.CreatePen(PS_SOLID, 4, RGB(255,0,0));
CDCPoint->SelectObject(&penObject);
CDCPoint->MoveTo(100,100);
CDCPoint->LineTo(100,200);
Why the line is in colour BLACK instead of RED??????
Also, when i put:
CDCPoint->MoveTo(100,100);
CDCPoint->LineTo(100,100);
It cannot print a dot. It prints nothing.....do you know why????
|
|
|
|
|
Where does CDCPoint come from? If you're playing with memory device contexts, and your line is black instead of red, you've probably screwed calling CreateCompatibleBitmap. Does your code look like this?
CDC CDCPoint;
CDCPoint.CreateCompatibleDC(pSomeOtherDC);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&CDCPoint, cx, cy);
CDCPoint.SelectObject(&bitmap);
If yes, you need need to change first argument in CreateCompatibleBitmap from &CDCPoint to pSomeOtherDC. Currently, your bitmap is monochrome and red pen draws a black line.
Use MoveTo(100, 100) and LineTo(100, 101) to display a pixel. Better yet, call SetPixel(100, 100, RGB(...));
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
My program doesn't have CreatCompatibleBitmap...something liked that.....i just have in OnDraw(CDC* pDC):
if(CDCPoint==NULL)
{
CDCPoint=new CDC;
}
CDCPoint->m_hDC=pDC->m_hDC;
CDCPoint->m_hAttribDC=pDC->m_hAttribDC;
//creating a global window handler to help with output
Handler=m_hWnd;
//setting background mode so there wouldn't be a border around text (just in case)
pDC->SetBkMode(TRANSPARENT);
//setting fixed width font
CFont newFont;
newFont.CreateFont(18, 9, 0, 0, FW_REGULAR, 0, 0, 0, ANSI_CHARSET, OUT_DEVICE_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_MODERN, "Courier New");
pDC->SelectObject(&newFont);
Also, I found that there is another problem........normally the output font is Courier New....but suddently....all fonts change to another one....including all message box.
Thanks for your help anyway...
|
|
|
|
|
So what's the point of having CDCPoint variable? Isn't pDC enough?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
CDC* CDCPoint is a global variable for another files in the project. But pDC is just using in OnDraw().
Therefore, CDCPoint and pDC are the same but used in different area.
|
|
|
|
|
You shouldn't to copy HDC handles from pDC passed OnDraw to your global variable. They'll become invalid soon after OnDraw returns, b/c pDC will be released and your CDCPoint will be useless. Just perform your drawing using pDC. If using pDC instead of CDCPoint doesn't produce expected results, post your OnDraw handler code.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|