|
Hi,
I am playing around with resizing bitmaps and the GDI. I am trying to resize a bitmap from disk and then
display it in a CStatic.
Code As Follows:
// LOAD BMP FROM DISC
// ******************
HBITMAP testbmp;
testbmp= (HBITMAP) LoadImage(0,"C:\\test.bmp",IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
//CREATE SOURCE DC
//****************
CDC hdc;
hdc.CreateCompatibleDC(NULL);
hdc.SelectObject(testbmp);
//CREATE DESTINATION DC AND RELATED BMP
//*************************************
CDC destination ;
CBitmap bmp;
bmp.CreateCompatibleBitmap(&destination,100,100);
destination.CreateCompatibleDC(NULL);
CBitmap *old = destination.SelectObject(&bmp);
//PERFORM THE RESIZE
//******************
destination.StretchBlt(0,0,100,100,&destination,0,0,640,480,PATCOPY);
destination.SelectObject(&old);
//OUTPUT RESIZED BMP TO CSTATIC CONTROL
//*************************************
m_bmp.SetBitmap(*bmp);
Can anyone point out where I am going wrong
Cheers
Richard
|
|
|
|
|
You should use a BITMAP structure to get the size of your bitmap, but I assume it's really 640x480.
You can check out where you are going wrong by creating a CWindowDC like this
CWindowDC window(NULL);
Then you can draw your bitmap to this DC and it will go to the screen. That way you can tell if the bitmap has loaded, if it is being resized, etc., and so know where it's going wrong.
As to specifics, you should try passing the actual HINSTANCE into ::LoadImage, which you get from (from memory) AfxGetInstance(). Apart from that, if there's a glaring error there, it's too early in the morning for me to spot it ;0)
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
Hi,
How can I print the following two strings, "carpet", "lamp"
How can I: center, aling left, align righ , put tab space , and most importantly how can I put them on sepparate lines.
I know that printing is basicly like sending text to the screen, but I just don't know how to code it, basic syntax.
Thanks a lot guys.
|
|
|
|
|
Use the CDC::DrawText function.
|
|
|
|
|
Would it be possible to give me an example, please!
|
|
|
|
|
We get the Tooltips if we hover the mouse on some filename in Windows Explorer.
This Tooltip contains Type of File & Size.
How can I have the same functionality enabled with file type associated with my application.
Any clues where in the MFC App can it go in.
|
|
|
|
|
See part 8 of my shell extension series. At the end I have a blurb about customizing tooltips. Basically, in HKCR\.XXX you create a string value "InfoTip" and set it equal to the tip you want. Win 2K lets you put predefined properties in there as well.
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
Is there a function that can bring up a color picker dialog box?
Thank You
|
|
|
|
|
CColorDialog dlg;
if (dlg.DoModal()==IDOK)
{
COLORREF return = dlg.GetColor();
}
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
|
Can anyone tell me why this might not work on a windows 98 machine.. works fine on most 95, NT and 2000pro machines.. The txt file is not being created by the 98 machine.
//Operation that goes to the url and pulls the source
CString CUserProfileDlg::GetFile(const char *url, const Char *filename)
{
char httpbuff[HTTPBUFLEN];
TCHAR szCause[2048];
CString Cause;
Cause.Format("YES");
TRY
{
CInternetSession mysession;
CStdioFile *remotefile = mysession.OpenURL(url,1,INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_RELOAD);
CFile myfile(filename, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
int numbytes;
while (numbytes = remotefile->Read(httpbuff, HTTPBUFLEN))
{
myfile.Write(httpbuff, numbytes);
}
}
CATCH_ALL(error)
{
error->GetErrorMessage(szCause,2046,NULL);
Cause.Format("%s",szCause);
}
END_CATCH_ALL;
return (Cause);
}
//Operation of creating the text file
GetFile(strU+strB+strQ, _T("Source.txt")); //grabing html source
Thanks,
Rob Jones
|
|
|
|
|
Hello,
I am developing an application on WinNT 4.0, sp6 using VC++ sp5 and the application functions normally on that platform. However when I test it on W2k Adv Server, sp2, I notice that some controls "flicker" whenever the mouse cursor "hovers" over some of the controls. Does anyone have any pointers as to where I should begin investigating these strange occurances? Specifically, this flickering effect seems to occur with controls I have embedded in CToolbars and Stingray's Objective Grid, and NOT with controls in CFormViews. Are there specific window messages I should be intercepting with these controls (CComboBox's, CListBox's) so that they do not repaint needlessly?
Any pointers/suggestions are welcome. Thanks.
|
|
|
|
|
Hi,
Iam looking for good DirectDraw tutorial and basic program, which creates window and in fullscreen mode show text.
Thank you for links or program ...
Wizi
libor.bares@seznam.cz
|
|
|
|
|
|
Does any have the problem processing the VK_LEFT\VK_RIGHT key in CDialog?
I was trying to do an animation in dialog which a small bitmap will move around the dialog box when an arrow key is pressed (super mario style ), however I'm having problem processing the arrow keys in the OnKeyDown().
I tried to trace the messages, and it seems the window is getting the the WM_KEYDOWN message when an arrow key is pressed, but it just ignores it!! (No problem with keys like VK_DELETE, VK_END.. etc., tho).
Is there anything special I should know about processing the arrow keys in a dialog box?
Thanks!
|
|
|
|
|
OK, I just found out the answer.
The problem was in the WM_GETDLGCODE. Apparently window dosn't trust anybody but him self to handle the arrow key and tab keys.
What I did was just simply return DLGC_WANTMESSAGE in the the OnGetDlgCode() function. (Thanks, MSDN, for burying this tiny IMPORTANT notice in MILLIONS of articles)
|
|
|
|
|
How can you change the text color based upon a variable, in a Statusbar pane?? I still new at this. The identifiers of the statusbox are private and not reconized by the onctlcolor function. What can I do??? Need help??? Thanks in advance.
Thank-you
Sincerely,
RAH
|
|
|
|
|
i have an owner drawn CListCtrl with a subclassed ownerdrawn CHeaderCtrl.
i can successfully detect the item(s) i want to hide in both the CListCtrl::DrawItem() and
CHeaderCtrl::DrawItem() functions. i simply do not draw then. this is fine except that the
header control still draws the button like appearance of the column that i don't want.
does anyone know how to catch the message that is drawing this before DrawItem() is
called. and if so, what message is it?
am i even doing this right?
scott.
|
|
|
|
|
How I can paste a bitmap which is contain in the clipboard to a file? I really don't know how to do it. Could someone help me? Thank You.
Yours sincerely,
Raymond
Visual C++
|
|
|
|
|
Check out the bitmap saving class added to Code Project last week.
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
How I can paste a bitmap which is contain in the clipboard to a file? I really don't know how to do it. Could someone help me? Thank You.
Yours sincerely,
Raymond
Visual C++
|
|
|
|
|
Does any one have an example of exporting records/tables in an access.mdb file to a ascii text file in MFC.
Any help will be greatly appreciated.
ojacksonw@yahoo.com
ojacksonw@yahoo.com
|
|
|
|
|
I've been playing with ADO and it's pretty easy to read them out using ADO and access the records. It would be trivial to then write them to disk.
There are some ADO classes on this site ( not that I used them, but they should explain it better than I can )
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
Thanks for the response. Iwould appreciate any help with the code. I am able to add and delete records using DAO and I need a comma delimited text file to use with another program upon exporting.
thanks
|
|
|
|
|
someone can help me to implement a function that allows users to select a region of the screen with mouse ?
Thank
Leo.
|
|
|
|