|
Alpha Intelligence wrote:
And can I use Visual C++ to write C code
Simply name your file with a .c extension rather than .cpp, and DevStudio will use a C compiler in order to compile that file. You will need to be careful if you are trying to mix C compiled code with C++ compiled code however, because the C++ compiler will mangle the linker symbols in order to make function overloading possible.
|
|
|
|
|
Hi,
This must be really simple, but I am struggling with this. If I have a string such as:
TCHAR hex[] = "0AF79E00";
How can I convert this into a long variable so I know it means:
184,000,000
Is this possible?
Thanks in advance,
Simon
|
|
|
|
|
There are some articles in CP about it.
Check this and this
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
use sscanf:
TCHAR hex[] = "0x0AF79E00";
int value;
sscanf(hex, "%X", &value);
Chris Hafey
|
|
|
|
|
Cheers for the help guys. I'm now back on track.
Simon
|
|
|
|
|
I don't know how create a custom region!
thanks a lot!
|
|
|
|
|
You can call BeginPath on a DC, Then you could call your pie or chord function, and then End the path with EndPath, the path is stored inside of the region. Then you can call PathToRegion on that DC and a new region will be created with that path.
|
|
|
|
|
What's wrong with these code?Nothing appear in the screen!!!
void CMysView::OnPaint()
{
CPaintDC dc(this);
paintrect()
}
int CMyView::paintrect()
{
CPaintDC dc(this);
RECT rctA;
rctA.left = 20;
rctA.top = 30;
rctA.right = 180;
rctA.bottom = 230;
dc.Rectangle(&rctA);
return 0;
}
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
I think you're supposed to do your drawing in CView::OnDraw instead.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I know it ,but I want them outside OnPaint or OnDraw ,any way it solve
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
You get the paintDC twice in the same WM_PAINT message, afai remember that's not allowed and the second one won't work. If you passed the dc as a parameter to CMyView::paintrect instaed I bet it would work.
void CMysView::OnPaint()
{
CPaintDC dc(this);
paintrect(dc)
}
int CMyView::paintrect(CDC& dc)
{
RECT rctA;
rctA.left = 20;
rctA.top = 30;
rctA.right = 180;
rctA.bottom = 230;
dc.Rectangle(&rctA);
return 0;
}
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
thaaaaaaaaaaaaaaaanks,it woooooooooooooooooooorks
yohooooooooooooooooooooooooo
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Now I want to use paintrect outside the OnPaint or OnDraw.How can I do that?
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
You can pass the DC from OnPaint to your other drawing functions... so paintrect(CDC *pDC)...
|
|
|
|
|
CMyView::SomeFunctionOtherThanOnPaintOrOnDraw()
{
CClintDC dc;
paintrect (dc);
}
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Sorry, forgot the paramter to CClientDC::CClientDC
CMyView::SomeFunctionOtherThanOnPaintOrOnDraw()
{
CClientDC dc(this);
paintrect (dc);
}
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
The reason why this code will work instead is that in the constructor for CPaintDC, there is a call to BeginPaint in order to initialize the internal HDC. When begin paint is called, it sets something that is called the System region of the HDC.
For all intents and purposes, the System region is like a clipping region that cannot be changed. When you paint on a DC, the intersection of the system region, the clipping region, and the meta region are combined in order to give the developer the final region that is painted.
When a call to GetDC is made, the system region is set to the client area of the window.
When GetWindowDC is called, the system region is set to the window rect of the window.
When BeginPaint is called, the system region is set to the current invalid region of the window, then the invalid region is validated.
So, if you make two calls to BeginPaint, you will receive two successfully created DC's, however, the first one will contain a system region that has the invalid region set into it, and the second one will contain an empty second region. Therefore if you try to paint on the first region in one color, say blue, then it will succceed. Then if you try to paint on the second region in red, none of the operations would succeed because there is an empty second region.
|
|
|
|
|
How to load icon resource into hBitmap ?
thanx
|
|
|
|
|
Starting from an HICON , <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/icons_2227.asp">::GetIconInfo</a> fills an <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/icons_9eya.asp">ICONINFO</a> structure whose hbmColor member is the HBITMAP you're looking for.
An alternative method is to draw your into a bitmap DC.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanx
|
|
|
|
|
How to get the export table of a given module using c/c++ (such as quickview in winnt4 or DEPENDS.EXE from vs6)
thanx
|
|
|
|
|
You need to navigate through the Executable or DLL file. Most likely it will be in the windows PE format that was created for windows programs from 9x on.
I have done this quite alot, and what I have found the easiest is to map the file that you are interested in memory, and get a pointer to the base address of this file.
Next you can read through the entire file like it was a pointer to memory. At the base address of this file you will find a structure called:
PIMAGE_DOS_HEADER
from here you will be able to navigate through the EXE by the pointers and offsets that you are able to extract from that original header.
I can't remember the rest of the path right off of the top of my head, but if you search MSDN for Matt Pietrek's PEDUMP program, it will give all of the information that you need, and you can use most of the source code that he has written in order to get the export table that you want.
|
|
|
|
|
I would like to create a global variable which can be available in all my files of my MFC project.
Where must i declare it? (in which file ?)
thk you in advance
Appstmd
|
|
|
|
|
Try declaring it in stdafx.cpp, such as this:
<br />
int g_iCount;<br />
Then declare this variable externally in stdafx.h, this will allow all of the files in your project
to use it.
<br />
extern int g_iCount;<br />
This will work for all Visual C++ projects.
|
|
|
|
|
You can declare it as a member variable of your CWinApp derived class. Then from anywhere in your program, use AfxGetApp() to get a pointer, cast it to your derived class, and access the member variable.
I think it's better than using explicit C style globals.
Just my opinion though.
Nish
My most recent CP article :-
A newbie's elementary guide to spawning processes
www.busterboy.org
|
|
|
|