|
A local variable is likely in the cache, so it is more effiecint.
A static one may be far from the current instruction.
|
|
|
|
|
|
KellyR wrote: Is it more efficient ...
You can only find that out by testing. Testing with real data, that is.
And before you spend time for this, you should really be sure that this function call is a bottleneck of your application.
So - profile it! While processing real data!
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
I want to put it at the top part of client for the customer to pick up thumbnail to the client. Like this:
/-------------------------------------------------------\
| /--------------------------------------------------\ |
| |:laugh::laugh::laugh::laugh::laugh::laugh::laugh::laugh::laugh::laugh::laugh::laugh::laugh::laugh::laugh::laugh::laugh::laugh::laugh::laugh::laugh::laugh:| |
| |--------------------------------------------------| |
| |
| |
| |
\-------------------------------------------------------/
|
|
|
|
|
Do you want to have thumbnails of images on the listctrl of left to right?
|
|
|
|
|
|
On the Listctrl you have a option its name is Alignment you can set it to top or left.
|
|
|
|
|
Hi,
I am converting my MFC project from a dialog-based application to a single document interface. My dialog box contains a button which calls DoModal() on a Server-site dialog written by our company. Normally, this would bring up a window showing all of the services available on a server. This works fine and dandy in my dialog-based version of the project; however, in my new SDI application (in which the main dialog window from the first project fills the child view), calling DoModal() no longer brings up another window. I tried putting DoModal() code for both the server-site dialog and some of my own process status threads all over the project (inside the main dialog class, inside the child view class, and inside the application class), and nothing works. The only modal dialog I can bring up in the entire project is the about box which was already pre-coded. If anyone has any clue as to why DoModal() fails in my SDI application, please let me know.
|
|
|
|
|
Can you put a bit of code, about how are you doing that?
If you are in MFC (I guess with wizard, because of the About.. box) it should be easy to do. The easiest way is to make the dialog in the resource editor, then create a class to that dialog and then make the call like:
OnButtonClick ()
{
CMyDialog newDlg;
if (IDCANCEL == newDlg.DoModal ())
{
return;
}
return;
}
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
I am writing exactly what you put, yet it does not bring up a modal dialog box. If I debug, I can step into the DoModal() function to see what's wrong, and it looks like it fails when checking if lpDialogTemplate is NULL:
<br />
INT_PTR CDialog::DoModal()<br />
{<br />
ASSERT(m_lpszTemplateName != NULL || m_hDialogTemplate != NULL ||<br />
m_lpDialogTemplate != NULL);<br />
<br />
LPCDLGTEMPLATE lpDialogTemplate = m_lpDialogTemplate;<br />
HGLOBAL hDialogTemplate = m_hDialogTemplate;<br />
HINSTANCE hInst = AfxGetResourceHandle();<br />
if (m_lpszTemplateName != NULL)<br />
{<br />
hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG);<br />
HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG);<br />
hDialogTemplate = LoadResource(hInst, hResource);<br />
}<br />
if (hDialogTemplate != NULL)<br />
lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);<br />
<br />
if (lpDialogTemplate == NULL)<br />
return -1;<br />
|
|
|
|
|
Errr...sorry about that code snippet, I evidently used the wrong tags. By the way, this code is from dlgcore.cpp. Also, the code continues past the return -1 statement, I just didn't include it because it stops right there.
|
|
|
|
|
I was wondering how I could take screenshots using PrintWindow() on Windows XP and get the transparency information, so I don't get an ugly black border around all my individual window screenshots. This seems to be possible from looking at other programs (e.g. TopDesk, http://www.otakusoftware.com/topdesk/). I played with calling GetLayeredWindowAttributes to find out transparency information, but it only succeeds for app that initially set the transparency information in the first place.
|
|
|
|
|
I haven't tried this, but what happens if you create a 32-bit ARGB DIB section and select it into the destination DC?
Fill it with transparent pixels before the PrintWindow() call.
Of course, to preserve the transparency when saving to a file, you'll need to use a file
format that supports transparency, like PNG or TIFF.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I'm using C# with interop. I'm not too sure what you mean by "dib section," although I am creating a 32-bit ARGB bitmap where the image is written to. I tried making the bitmap transparent first, and also tried something like coloring all the pixels red first. Neither worked; every pixel is always overwritten. There is always a black border, and when I try to access the pixel at 0,0 (which on my computer should be transparent, because its a Windows XP rounded corner), it is always black with an alpha value of 255.
My C# code looks like this:
Rect rc;
GetWindowRect(hwnd, out rc);
if (rc.Width == 0 && rc.Height == 0)
{
return null;
}
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap((int)rc.Width, (int)rc.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
bitmap.MakeTransparent();
System.Drawing.Graphics gfxBitmap = System.Drawing.Graphics.FromImage(bitmap);
IntPtr hdcBitmap = gfxBitmap.GetHdc();
PrintWindow(hwnd, hdcBitmap, 0);
gfxBitmap.ReleaseHdc(hdcBitmap);
gfxBitmap.Dispose();
|
|
|
|
|
You're doing the same thing I was referring to
MakeTransparent() isn't going to help here. I would try actually clearing the bitmap to
transparent pixels with a transparent brush before calling PrintWindow().
What are you doing after the code you've shown? How do you check and see the undesired black border?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ok, I think I figured it out. The reason why the windows I was interested in were transparent wasn't because they were layered-- they had clipping window regions! Your hint about clearing the bitmap to transparent pixels was also helpful (I was drawing a transparent rectangle, but that doesn't work; you need to call clear).
Here is my final code. You can get the Win32/GDI functions through pinvoke.net
Rect rc;
GetWindowRect(hwnd, out rc);
if (rc.Width == 0 && rc.Height == 0)
{
return null;
}
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap((int)rc.Width, (int)rc.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
System.Drawing.Graphics gfxBitmap = System.Drawing.Graphics.FromImage(bitmap);
IntPtr hdcBitmap = gfxBitmap.GetHdc();
PrintWindow(hwnd, hdcBitmap, 0);
gfxBitmap.ReleaseHdc(hdcBitmap);
IntPtr hRgn = CreateRectRgn(0, 0, 0, 0);
GetWindowRgn(new IntPtr(hwnd), hRgn);
System.Drawing.Region region = System.Drawing.Region.FromHrgn(hRgn);
if (!region.IsEmpty(gfxBitmap))
{
gfxBitmap.ExcludeClip(region);
gfxBitmap.Clear(System.Drawing.Color.Transparent);
}
gfxBitmap.Dispose();
|
|
|
|
|
Cool! Thanks for the update
I'll try to remember that the next time it comes up!
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Dear All
i am about to start a project something like download manager Like FlashGet....etc
i need to know how to start ??
i need any info. about the following :
"limit download speed"
"resume, pause, stop"
i need any tips
thanks
bye
|
|
|
|
|
Adore C++ wrote: i need to know how to start ??
Maybe with something a little less ambitious. Not to dull your knife or anything, but you can't jump into the deep end of the pool and then immediately ask for help. Start small and build upon that.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: you can't jump into the deep end of the pool and then immediately ask for help.
Sweet, let's make an acronym out of that: The Internet
|
|
|
|
|
|
I installed Norton Antivirus a few days ago, and I was pretty surprised to find that it can't be terminated. Tried the End Process thing, and all I get is a msgbox telling me that "Access is denied".
My question: Is there a way to do this in a MFC app? Either by making the app a system process or by starting another process that somehow isn't endable?
And is there any way to end processes like these? Sometimes Norton takes up so much CPU it's annoying, and yet I can't end the process...
Thanks in advance.
Edit: I don't want to start another topic, so I'm just going to add another unrelated question: By using ::SendMessage(), is there any way to tell a listbox (like the one in task manager) to remove ONE entry if I know the contents of that entry?
-- modified at 14:24 Monday 19th November, 2007
|
|
|
|
|
This is intentionally difficult to do.
Part of how virus programs protect themselves is by terminating the anti-virus programs. And anti-virus programs protect themselves by making them very difficult to terminate.
If it's that annoying to you, I suggest you uninstall it in favor of some other program.
I'm not quite sure how Norton does it though...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
Norton accomplished this with a kernel hook from a device driver.
Normally here is what happens:
1.) User program invokes TerminateProcess() is called from kernel32.
2.) TerminateProcess() calls NtTerminateProcess() exported from NTDLL.DLL.
3.) NtTerminateProcess() invokes ZwTerminateProcess()
4.) ZwTerminateProcess() will mov 0x101 into eax and mov edx,esp.
5.) SYSENTER instruction is executed.
Looks something like:
TerminateProcess()
...
call ds:NtTerminateProcess
...
mov eax, 101h
mov edx, 7FFE0300h
call edx
.text 7FFE0300: mov edx,esp
systenter
ret
However, Norton has implemented a ZwTerminateProcess hook by modifying the SDT (Service Descriptor Table) so at this point they have intercepted the call and their code executes instead, blocking you from terminating the application.
|
|
|
|
|
Could you give an example of how I might do this in my code?
Thanks.
|
|
|
|