|
Iain Clarke wrote: GDI+ is just build on top of GDI.
In general this isn't the case. Here's an except from MSDN (underlines are mine):
Microsoft Windows GDI+ is a class-based API for C/C++ programmers. It enables applications to use graphics and formatted text on both the video display and the printer. Applications based on the Microsoft Win32 API do not access graphics hardware directly. Instead, GDI+ interacts with device drivers on behalf of applications. GDI+ is also supported by Microsoft Win64
GDI+ talks to the display driver using an interface know as DCI.
Steve
|
|
|
|
|
I knew it had some side paths - but I learn new things every day. Thanks for filling in the gaps I left.
Iain.
|
|
|
|
|
In addition to Iain's reply....
Make sure to call Graphics::ReleaseHDC() when you're done with the DC.
Any calls using the Graphics object will fail until you do
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
If your using antialiasing, then the ideas posted about using GDI may look kinda funny alongside your other graphics primitives.
I've tried it before and ones eyes tend to get upset if you mix blurry antialiased with edged drawing primitives from GDI. It's best to be consistent within a certain space. Having standard menus with antialiased graphics in the client area of the view seems to work without giving one a headache.
There is an article about RoundRects in GDI+ here on CP. It's a roll your own implementation but it seems that it's a common approach for those seeking that functionality while allowing GDI+ antialiasing.
An approach to RoundRect by Mr. Graus[^]
|
|
|
|
|
Add a round rectangle to a GraphicsPath object and then pass that object to the Graphics::DrawPath() function. Here is a code to add a round rectagle to a graphics path
void GetRoundRectPath( const CRect& rect_i, int nRad_i, Gdiplus::GraphicsPath& path_o )<br />
{<br />
int nX1 = rect_i.left;<br />
int nY1 = rect_i.top;<br />
int nX2 = rect_i.right - 1;<br />
int nY2 = rect_i.bottom - 1;<br />
int nDia = nRad_i * 2;<br />
<br />
path_o.AddArc( nX1, nY1, nDia, nDia, 180, 90 );<br />
path_o.AddArc( nX2 - nDia, nY1, nDia, nDia, 270, 90 );<br />
path_o.AddArc( nX2 - nDia, nY2 - nDia, nDia, nDia, 0, 90 );<br />
path_o.AddArc( nX1, nY2 - nDia, nDia, nDia, 90, 90 );<br />
path_o.CloseFigure();<br />
}
|
|
|
|
|
Following code is copied from Ms HtmlHelp.h
//============================================
enum {
HHACT_TAB_CONTENTS,
HHACT_TAB_INDEX,
HHACT_TAB_SEARCH,
HHACT_TAB_HISTORY,
HHACT_TAB_FAVORITES,
HHACT_EXPAND,
HHACT_CONTRACT,
HHACT_BACK,
HHACT_FORWARD,
HHACT_STOP,
HHACT_REFRESH,
HHACT_HOME,
HHACT_SYNC,
HHACT_OPTIONS,
HHACT_PRINT,
HHACT_HIGHLIGHT,
HHACT_CUSTOMIZE,
HHACT_JUMP1,
HHACT_JUMP2,
HHACT_ZOOM,
HHACT_TOC_NEXT,
HHACT_TOC_PREV,
HHACT_NOTES,
HHACT_LAST_ENUM,
};
typedef struct tagHHNTRACK
{
NMHDR hdr;
PCSTR pszCurUrl; // Multi-byte, null-terminated string
int idAction; // HHACT_ value
HH_WINTYPE* phhWinType; // Current window type structure
} HHNTRACK;
//======================================================
My Q is:
how to use the struct tagHHNTRACK in HtmlHelp() function?
the constant HHACT_EXPAND sounds good for my use.
thx.
|
|
|
|
|
Hi,
Can I use the listctrl of the windows explorer in my application? I mean I want to use the explorer window, but only need that listctrl in which the files and folder are displayed.
Thanks in advance.
- NS -
|
|
|
|
|
Why exactly would you want/need to do this? Can't you just add a list control to your application and code it up to do what Explorer's does?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I was just intended to avoid extra coding. I am not sure whether it is possible or not.
- NS -
|
|
|
|
|
There's an article here on CP about doing that in Vista. It mentions that it's possible (although harder) in previous OSes as well.
|
|
|
|
|
|
Thanks
- NS -
|
|
|
|
|
Thanks for the hint. I shall ofcourse try...
- NS -
|
|
|
|
|
Hello. How can I determine whether a directory is shared? I thought that traditional FindFirstFile and WIN32_FIND_DATA would provide me the answer, but it doesn't.
Thanks in advance.
Hope is the negation of reality - Raistlin Majere
|
|
|
|
|
|
Thanks!
Hope is the negation of reality - Raistlin Majere
|
|
|
|
|
You can use NetShareEnum API
AJay
|
|
|
|
|
I have created a custom message for one of my windows. For the sake of argument lets call it CUSTOM_MESSAGE. So I use the sendmessage code as follows:
char *text;
SendMessage(hwnd, CUSTOM_MESSAGE, 0, (LPARAM)text);
In the destination window's message procedure, I want it to set the value of text (the LPARAM value), and make this value availible to the previous bit of code, as shown below
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
...
switch(msg)
{
...
case CUSTOM_MESSAGE:
//Set the value of the LPARAM and allow the previous bit of code to receive and use this value
break;
...
}
...
}
So, once SendMessage() has been called, the other bit of code can use the text variable, which has been set by the destination window's window procedure, as shown:
char *text;
SendMessage(hwnd, CUSTOM_MESSAGE, 0, (LPARAM)text);
MessageBox(NULL, text, "Message", MB_OK);
How would I go about doing this?
Thanks for your help!
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
You should allocate memory for the LPARAM parameter before sending message,because you can't access to NULL pointer.
char *text;
SendMessage(hwnd, CUSTOM_MESSAGE, 0, (LPARAM)text);//text==NULL
|
|
|
|
|
Good point. Thanks
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
To those who said running an exe from within the resource section is impossible :p I did it!
But, here's a problem that is turning my hair grey. The exe I'm running ( a console app from a console app ) loads a single dll ( FooBar.dll ), This dll in turn loads kernel32. The problem is, when the loaded exe finishes execution, ExitProcess() is called from within FooBar.dll.
Now I need to trap this and return back to my main program, but everything I have tried so far just doesn't work. I'm guessing I need to set a hook and all the tuts I have read on the subject say to create and inject a dll. Is this really necessary to hook an api call for my own process?
|
|
|
|
|
If the hooking you want to do is for your own process you do not need to inject a DLL (although it is pretty fun :p) - you can call it from your application using the SetWindowsHookEx() command. For your case, however, I don't believe that you can use hooking, as ExitProcess doesn't send a message to a window - check out MSDN to read up on the SetWindowsHookEx() command.
I'm slightly puzzled; ExitProcess() calls DLL_PROCESS_DETACH in your DLL. Now if FooBar.dll is yours and you have code for it.. Why can't you write some code in the DLL_PROCESS_DETACH code in the DllMain() procedure in your DLL to see why the DLL is exiting and, if so, trapping it? Might that be a way to do it?
Hope this helps!
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
Perspx wrote: ExitProcess doesn't send a message to a window
This is exactly the problem I am facing, even more so with a console app.
I need some method of trapping any call to ExitProcess() from anywhere within my process and redirect the call to my own handler. The catch is, my own exe loads the address, which I can alter, the app I load from the resource also links to ExitProcess, again I can edit the IAT; AND the dll it loads also links against ExitProcess, but this time I can't edit the address.
FooBar.dll is my own and editing the code would solve the problem, but what about future apps where I might not have the code.
Is there any way I could hook Kernel32.dll directly, or would having a fake kernel32.dll in the apps directory solve the problem?
|
|
|
|
|
You may be able to hook Kernel32.dll directly with SetWindowsHookEx(), and use the WH_CALLWNDPROC hook ID, assuming that this works with DLL procedures. You could then trap the DLL_PROCESS_DETACH message and do what you like with it, to stop it exiting.
Note that Windows is very annoying (understatement) when it comes to its own resources. You may not be able to link Kernel32.dll at runtime, especially if it is owned by another process or in use (there are lots of annoying "security" things with Windows). I also am not too sure if you can hook Kernel32.dll, because, again, Microsoft may have considered security here and protected the kernel from being modified or used by another application, so bear this in mind also.
Hope this helps!
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
I actually have a lot of experience with hooking api's in the fashion made famous by Microsoft's "Detours" library.
The idea is that you patch the actual first few CPU instructions of the target function itself, rather than patching the Import Address Table.
This is good because it catches EVERY call to the function no matter from where, or how it is being called.
The patching itself is made possible by a feature of Windows memory management called "COPY_ON_WRITE", which basically means that if you write to the memory containing the target function, Windows is kind enough to copy that page of memory to a new place, and assign it to your process only.
This solves problems that arise from memory that contains DLL code being shared between processes. In effect, you process receives its own private copy of the page that was altered, while all other processes continue to use the unaltered version of that particular page of memory.
I am happy to help you implement this, if you decide you want to. Please do some web searches for the Microsoft Detours Library, and see if you can pick up what you need to know, otherwise I can help you.
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|