|
Do you want to send WM_MINIZED to other programs?
|
|
|
|
|
Hi, I'm using VS2005Pro developing in C.
I remember being able to begin a comment section and VS would put in a template depicting function name, return value and a parameter list. Of course, the developer would have to fill in the blanks (as it were).
I thought it was something akin to '///' and on the third '/', the template would appear that I could fill in.
Does someone else know what the correct key sequence is?
Is this something that only happens for C# && C++?
Thanks!
|
|
|
|
|
Hi CP,
I have a deployment project on VC2005 SP1 and it creates a Setup.exe and a .msi file, and other prerequisite files. Actually prerequisites are Windows Installer setup files, what's really necessary for application installation is only .msi but Setup.exe is needed for me since it can get a sufficient privilege for UAC in Vista to work correctly. Directly clicking on .msi starts installation but it stops by an error in a custom action in my deployment project that requires a elevated privilege.
Basically what I want to know is how to prevent a user from clicking .msi instead of Setup.exe, I have seen other applications do it, it says "don't click .msi directly, click Setup.exe" but couldn't find how to do it without InstallShield and other products. Editing .msi with Orca is probably what I should do but can't find a relevant part.
Can anybody help me to figure it out? Thanks in advance.
|
|
|
|
|
Other forums could not get the answer my this question: When my dialog activate the text-cursor activate where in the editbox. How can I do to do this? Have you got an idea? or sample code?
What is this¿
|
|
|
|
|
What are you wanting to happen?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hakan Bulut wrote: When my dialog activate the text-cursor activate where in the editbox.
I'm not certain I understand what you want to do; maybe it's just a language issue.
|
|
|
|
|
Can you more explain what do you need exactly?
|
|
|
|
|
I am creating a small image viewer interface in MFC to do some processing on our research images which are very big in size (5000x3000). In that I am using StretchBlt to display image on DC, this works fine when I am using a scale of 1:1, but when I increase the scale, the display refresh is very slow when I use the scroll bar and the image becomes very bad when I compress an image (but I dont need to compress an image though). Is there any alternative to stretchblt().
Looking at CImage class, I can create an Image object from my current HBITMAP.
Looking at Image class from GDI+, I didnt see any constructor for Image object from HBITMAP.
Any suggestions???
thanks in advance,
-PNT
PKNT
|
|
|
|
|
Have you look at the articles here on CodeProject?
Here is one example[^]
|
|
|
|
|
instead of restretching with each redraw, you might be better off stretching once to a second bitmap, then re-blting that stretched bitmap for normal OnPaint handling.
|
|
|
|
|
I tried this way, but it displays just a white page... here is how I did it
working version
CClientDC dc(this);<br />
dib->Draw(&dc,x,y);
where dib->Draw function is defined as below-
void DIBSection::Draw(CDC* pdcDest, int xs, int ys) <br />
{<br />
pdcDest->BitBlt( 0, 0, m_size.cx, m_size.cy, m_pdc, xs, ys, SRCCOPY);<br />
}
modified version
CDC* m_pdc = new CDC ;<br />
m_pdc->CreateCompatibleDC(NULL);<br />
dib->Draw(m_pdc, 0, 0, w*zoom_const, h*zoom_const, 0, 0, w, h);<br />
CClientDC dc(this);<br />
dc.SelectObject(m_pdc);<br />
dc.BitBlt(0, 0, w*zoom_const, h*zoom_const, m_pdc, 0, 0, SRCCOPY);
where w, h are width and height of my image and zoom const is the scaling factor. dib is an object of my DIBSection class. dib->Draw does nothing more except it calls the dc->BitBlt function with its own defined dc in the Blt function, which is created when the dib object is created with bitmap data.
am I doing something wrong here??
-PNT
PKNT
|
|
|
|
|
Kiran Satish wrote: dc.SelectObject(m_pdc);
you can't select a DC into another DC.
you need to create a compatibleDC, create a compatibleBitmap (of the scaled size), select that btimap into that DC, then BitBlt from your source DC onto the scaled DC/bitmap. then you can use that scaled bitmap to draw
|
|
|
|
|
Thanks for the reply, I tried as you suggested...
<br />
CClientDC dc(this);<br />
CDC tempDC;<br />
tempDC.CreateCompatibleDC(NULL);<br />
CBitmap tempBMP;<br />
tempBMP.CreateCompatibleBitmap(&tempDC, w*zoom_const,h*zoom_const);<br />
tempDC.SelectObject(tempBMP);<br />
dib->Draw(&tempDC, 0,0,w*zoom_const,h*zoom_const,0,0,w,h); <br />
dc.BitBlt( 0, 0, w*zoom_const,h*zoom_const, &tempDC, sp.x, sp.y, SRCCOPY);
it still shows me a black image.... am I still doing wrong??, sorry I am not soo familiar with CBitmaps and DCs. Just learning now
-PNT
PKNT
|
|
|
|
|
Kiran Satish wrote: dib->Draw(&tempDC
what is Draw expecting as its first parameter (CDC, HDC, CDC*) ?
as a test, you might try something simple like drawing a rectangle (CDC::FillSolidRect) on that tempBMP, just to see if maybe the problem is in the Draw function.
also tempDC.SelectObject(tempBMP); should probably be tempDC.SelectObject(&tempBMP);
|
|
|
|
|
That draw function is same before...
<br />
void DIBSection::Draw(CDC* pdcDest, int x, int y, int nw, int nh, int xs, int ys, int w, int h)<br />
{<br />
pdcDest->StretchBlt( x, y, nw, nh, m_pdc, xs, ys, w, h, SRCCOPY);<br />
}
where m_pdc is the DC of dib where the actual pixel data is stored.
will try the simple fillrect function.
-PNT
PKNT
|
|
|
|
|
I tried to fill the DC with RED color and it still shows up as 300x300 black image ...
tempDC.SelectObject(&tempBMP);<br />
tempDC.FillSolidRect(0,0,300,300,RGB(255,0,0));<br />
dc.BitBlt( 0, 0, 300,300, &tempDC, 300, 300, SRCCOPY);
-PNT
PKNT
|
|
|
|
|
when you call CreateCompatibleBitmap, try giving it the DC you're going to BitBlt it to, not the temp DC.
|
|
|
|
|
Yeh.. tht made it work... but if you dont mind, could you tell me why it is like tht??
thanks,
-PNT
PKNT
|
|
|
|
|
the Bitmap needs to be compatible with the DC you're BitBlt'ing to. when you use the memory DC for the C*C*Bitmap call, the bitmap created will be monochrome. if you use an output DC, it will match the settings of that DC.
or, as Microsoft puts it:
Because memory device contexts allow both color and monochrome bitmaps, the format of the bitmap returned by the CreateCompatibleBitmap function differs when the specified device context is a memory device context. However, a compatible bitmap that was created for a nonmemory device context always possesses the same color format and uses the same color palette as the specified device context.
Note: When a memory device context is created, it initially has a 1-by-1 monochrome bitmap selected into it. If this memory device context is used in CreateCompatibleBitmap, the bitmap that is created is a monochrome bitmap. To create a color bitmap, use the hDC that was used to create the memory device context, as shown in the following code...
|
|
|
|
|
It working definitely better than before, but what I am trying to do now is, rather than doing this work everytime I update/refresh the window, is there any way I can reduce this work, but doing this only once for each zoom constant? For now, this is how it goes..
CClientDC dc(this);<br />
CDC tempDC;<br />
tempDC.CreateCompatibleDC(NULL);<br />
CBitmap tempBMP;<br />
tempBMP.CreateCompatibleBitmap(&dc, w*zoom_const,h*zoom_const);<br />
tempDC.SelectObject(&tempBMP); <br />
dib->Draw(&tempDC, 0,0,w*zoom_const,h*zoom_const,0,0,w,h); <br />
dc.BitBlt( 0, 0, w*zoom_const,h*zoom_const, &tempDC, sp.x, sp.y, SRCCOPY);
where sp is the scroll position. But lets say I scrolled the image, in this case the zoom constant is still the same, I just need to update the position of the image wrt view window. I see stretching the bitmap all the time is very time consuming .
thanks,
-PNT
PKNT
|
|
|
|
|
create a CBitmap object member of your window class. every time your zoom level changes:
1. delete the contents of that CBitmap
2. create a new (compatible) bitmap of the appropriate size
3. do your StretchBlt onto that
the code to do that is basically the same as what you have above, but you drawing into m_zoomedBitmap (or whatever) instead of tempBMP, and you use StretchBlt there.
then, when it's time to do the OnPaint/OnDraw, draw that member CBitmap with a normal BitBlt.
|
|
|
|
|
I tried exactly what you said (I hope), declared a CBitmap member in Document class and using it instead of tempBMP like below..
CClientDC dc(this);<br />
if (zoom_const >1)<br />
{<br />
CDC tempDC;<br />
tempDC.CreateCompatibleDC(NULL);<br />
if (m_bZoomUpdate)
{<br />
GetDocument()->m_zoomedBMP.CreateCompatibleBitmap(&dc, w*zoom_const,h*zoom_const);<br />
tempDC.SelectObject(&GetDocument()->m_zoomedBMP);<br />
dib->Draw(&tempDC, 0,0,w*GetDocument()->zoom_const,h*GetDocument()->zoom_const,0,0,w,h); <br />
m_bZoomUpdate = false;<br />
}<br />
else<br />
tempDC.SelectObject(&GetDocument()->m_zoomedBMP);<br />
dc.BitBlt( 0, 0, w*zoom_const,h*zoom_const, &tempDC, sp.x, sp.y, SRCCOPY);<br />
}<br />
else
dib->Draw(&dc, 0,0,w*zoom_const,h*zoom_const,sp.x,sp.y,w,h);
It works... and the drawing is as normal with no delays... Now time for getting the exact location of a pixel in zoom mode .
thanks,
-PNT.
PKNT
|
|
|
|
|
It's working fine on both small and large image files. But the only problem that I found is the stretching doesnt work after reaching certain zoom level. I tried 3 different sizes of images,
one is 1000x1000 and it works fine for the whole zoom range that I have (1x - 5x)
second image is 3616x3581 and it works fine untill 2.1x and shows only a white image after that (at 2.2x its dimensions are 7593x7520)
and the third image is 5540x3615 and it works only untill 1.7x and from then shows only white image (at 1.8x its dimensions are 9972x6507).
Is there any limit on the max size of a compatible bitmap that you can create??
thanks,
-PNT.
PKNT
|
|
|
|
|
Kiran Satish wrote: Is there any limit on the max size of a compatible bitmap that you can create??
yes, definitely.
it varies from system to system, though.
|
|
|
|
|
I am back with a problem closely related to this topic... everything is fine and was able to magnify the images upto the point when I load images of 40MB in size. Then this function behaves differently on different machines (same OS) except on one machine with 64bit OS (where it can magnify to any scale without problem). On some machines it doesn't even magnify one step and on some machines it magnifies to few steps (after that it just shows either white or black frame when you try to magnify). Here is the code that I am currently using-
if (GetDocument()->zoom_const >100)
{
CDC tempDC;
tempDC.CreateCompatibleDC(NULL);
if (GetDocument()->m_bZoomUpdate)
{
GetDocument()->m_zoomedBMP.DeleteObject();
GetDocument()->m_zoomedBMP.CreateCompatibleBitmap(&dc, w*GetDocument()->zoom_const/100,h*GetDocument()->zoom_const/100);
tempDC.SelectObject(&GetDocument()->m_zoomedBMP);
dib->Draw(&tempDC, 0,0,w*GetDocument()->zoom_const/100,h*GetDocument()->zoom_const/100,0,0,w,h);
GetDocument()->m_bZoomUpdate = false;
}
else
tempDC.SelectObject(&GetDocument()->m_zoomedBMP);
dc.BitBlt( 0, 0, w*GetDocument()->zoom_const/100,h*GetDocument()->zoom_const/100, &tempDC, sp.x, sp.y, SRCCOPY);
}
else
dib->Draw(&dc, 0,0,w*GetDocument()->zoom_const/100,h*GetDocument()->zoom_const/100,sp.x,sp.y,w,h);
Is there any other way to do this more efficiently and overcome this problem.
thanks,
PKNT
|
|
|
|
|