|
Hi all,
Iwould like to load a bmp picture in to my dialog during runtime and if the actual size of the bitmap is less than my dialogs view area the bitmap should be displayed as such exactly in the centre and if its size is greater the dialogs view area the bitmap should confine to the view area with scrolling capability.How can i achieve this?.Can anyone help me?.
With regards
Shibu
|
|
|
|
|
The scrolling is an issue, the rest is easy. Assuming you have a HBITMAP ( which a CBitmap can return ) you can do this:
BITMAP bm;
GetObject( bm, sizeof(BITMAP), myhBitmap);
This structure tells you the width and height of your bitmap, the rest is simple maths. Draw the bitmap using BitBlt in your WM_PAINT handler, and if you want scrolling, you'll also need to draw two scrollbars, and use GetClientRect to find out the size of your dialog, then make the scroll range of each equal to the size of the bitmap - the size of the screen. i.e. if your bitmap is 200 wide and your dialog is 150 wide, you need the scrollbar to have a range of 50, so you can scroll across to see all of it. Then handle the scroll messages, and in them invalidate your dialog. Your draw routine should now draw the bitmap taking into account the scroll pos of the two scrollbars.
To centre, it's just some basic math. And you're done.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
Hi, recently I came across the following code and was wondering if you could help me understand some syntax.
#if 0
for (int i = 0; i < _Points; i++)
_aTape[i] = 1600 * sin (2 * PI * 1000. * i / _sampleRate);
#else
for (int i = 0; i < _Points; i++)
_aTape[i] = 0;
#endif
What are these #if and #else directives. Are they like the normal if/else. Also, what does the #if 0 evaluate to???
Thanks for any reply.
Cheers,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
#if, #else and #endif are preprocessor directives. #if 0 is used to quickly comment out part of the code. In your case, only the second version of the loop will be compiled.
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
hmmmmm... I wonder why the guy used it then. I mean, if I understood you correctly only the second version of the loop will ever get executed, right?
Thanks,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
pankajdaga wrote:
I wonder why the guy used it then
He can quickly switch between two versions of the loop by changing '#if 0' to '#if 1' and recompiling. It's easier that using /* and */
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Got it! Thanks man!
Pankaj
Without struggle, there is no progress
|
|
|
|
|
Hi
I'm trying to set item image with this code:
CImageList m_ImageList;
m_ImageList.Create(IDB_BITMAP1,18,10,(COLORREF)0xFFFFFF);
int nCount = m_ImageList.GetImageCount();//after that nCount == 7
m_Tree.SetImageList(&m_ImageList,TVSIL_NORMAL);
m_Tree.InsertItem( "text", 1, 1 );
, but it doesn't work properly. New added item has empty image(white) and looks like it would be shifted on the right (by the image width). I don't have the faintest idea what is wrong.
thanks for any help
|
|
|
|
|
|
Your m_imageList seems to be local variable, despite the m_ prefix. It's destroyed as soon as program leaves the scope; tree control is left with invalid image list handle.
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Great thanks
Of course solution was really simple and my mistake was really stupid but the most stupid errors are the most difficult to solve out.
|
|
|
|
|
hello
in my programm im lookin for some system information
how do i get information about:
the installed windows service pack
and the rights of the loged in windows user
(e.g. admin, power user)
I use VC++ 6 and W2k
|
|
|
|
|
can we call dynamic_cast in OnInitDialog
|
|
|
|
|
SPGV wrote:
can we call dynamic_cast in OnInitDialog
dynamic_cast is a C++ cast operator. You may use it anywhere in your C++ program [It has nothing to do with MFC or CDialog]
Read my article [URL below] for more info on C++ cast operators.
http://www.codeproject.com/managedcpp/castingbasics.asp
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Yes, assuming that RTTI is enabled in project settings (it's not by default in VC6).
What kind of problems are you experiencing?
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
|
Tomasz Sowinski wrote:
it's not by default in VC6
Guess what! It's not by default in VC7 too. Default compiler option is /GR- for MFC projects. My mistake was that I've done all my recent casting stuff on MC++ projects which have /GR and not /GR-
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Nishant S wrote:
Guess what! It's not by default in VC7 too.
I like that. If you want to use dynamic_cast and typeid, you'll better find some good reason and know what you're doing
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Hi,
I'm not sure if this is the right place to be asking this question, but if its not I'd be grateful if someone could suggest a good site to go to.
I am using eMbedded Visual C++ and created an application using the AppWizard (exe). It uses shared dlls. My problem is that I am not sure how to add the dlls to my installer package, and which dlls to add. When I was debugging the application on a mobile device it downloaded mfcce300d.dll to the device. I have tried adding this to the installer package but when I try and run the application after installation it says that there is a library or component missing. Any ideas anyone?
Thanks,
Graham
|
|
|
|
|
MFCCE300d.dll is the debugging version of the MFCCE300 library (hence the trailing 'd') and is only used when you run the debug version of your app. MFCCE300.dll is the release version and already exists on the device; you don't have to install it yourself.
You can use the dependency walker http://www.dependencywalker.com [^] to determine which DLLs your app uses (even for CE applications).
Google for EZSetup to find a free and open source simple CE installation package. See http://www.pocketpcdn.com/articles/ezsetup.html[^] for an article.
VictorV
|
|
|
|
|
I have a program that search text files in a path that user define.When I click search button it start searching,but the program freeze.So I decide to put this function in a thread.
First:Is that good idea to put it in a thread and does it solve the problem of freezing?I read in MSDN that in worker thread when controlling function exists the thread terminate.My controlling function is recursive function brcause I want to search through directories so is that caused error?
Second:My controling function begins like this:
<br />
UINT FindFile(LPVOID chPath)<br />
{<br />
<br />
CString strWildcard = (CString&)(chPath);<br />
<br />
if (strWildcard == "")<br />
return 1;<br />
<br />
CFileFind finder;<br />
<br />
strWildcard += _T("\\*.*");<br />
It always afetr CFileFind finder line,thrown an unhandled error.Any idea?
Third:How can I access my controls in my dialog inside my controlling funcion?Shoud it be ALWAYS a global function?
Thanks a lot
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Probably you're having problems with chPath. I guess you should change (CString & ) to (LPCTSTR), but you didn't post your call to AfxBeginThread.
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
CString str;
m_editpath.GetWindowText(str);
AfxBeginThread(FindFile,(LPVOID &)str);
Well,I change CString & to LPCSTR.I debug it and "strWildcard" is like this:
{0x003869e8 "îþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþ"} ATL::CStringT<char,strtraitmfc<char,atl::chtraitscrt<char>
But there is no difference.the problem happend at CFindFile line.Not at "strWildcard" line.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Your problem is quite interesting. First of all, you're passing a reference to local CString, which is destroyed as soon as you leave the scope. So, depending on timing issues, your FindFile function may get correct string or not.
Easiest (but not elegant) way to solve this problem is to use global variable. You may also allocate a CString on the heap and pass a CString pointer to AfxBeginThread. In this case, FindFile would have to delete the string after it's no longer used.
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Tomasz Sowinski wrote:
You may also allocate a CString on the heap and pass a CString pointer to AfxBeginThread.
Whats that?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|