|
The base class list is not terribly complete. You're going about it the right way, but you'll need to manually derive from those classes. Also, do you realise the code for CToolbar is installed with VC ? So you can look at what they do if you need ideas.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Ok cool, that's kinda what I figured.
As I said, I'm new to the MFC thing, so forgive me if this sounds dumb, but if I make a new class manually is that gonna screw anything up with the whole way the AppWizard junk works? Also, what's your take in general on using the AppWizard? It seems like in some ways it makes things a bit easier to manage, but the code it spits out is ugly and at this point I'm constantly worried that I'm gonna do something to trip it up. Any words of wisdom?
Also, that's cool that the CToolbar code is included. Do you happen to know where I'd find that, as well as other classes? I think looking at what they're doing for their classes might be a great way for me to really figure this stuff out.
Thanks!
-John
"Ask me about my vow of silence"
|
|
|
|
|
Teknofreek wrote:
if I make a new class manually is that gonna screw anything up with the whole way the AppWizard junk works?
To be honest, I'd suggest the sooner you learn enough to not use the appwizard, the better. But if you derive from another class instead, then go through your class and change what it derives from, it should be OK.
Teknofreek wrote:
Also, what's your take in general on using the AppWizard? It seems like in some ways it makes things a bit easier to manage, but the code it spits out is ugly and at this point I'm constantly worried that I'm gonna do something to trip it up. Any words of wisdom?
Dunno about wisdom, but I'd suggest the best approach is to learn how to do it all yourself, then use the appwizard for speed, knowing that if it screws up ( and it will ), you know how to fix it manually. There are no manly points for not using a time saving tool, but you should be be dependant on it.
Teknofreek wrote:
Do you happen to know where I'd find that, as well as other classes?
I believe there is an MFC sub directory in the whole structure of VC. To be honest, I can never remember. I'd just start at the top and do a find in files for something like CToolbar::, that's bound to bring it up. Also, often these things are defined across multiple files, so the CToolbar:: search should find them all.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Christian Graus wrote:
But if you derive from another class instead, then go through your class and change what it derives from, it should be OK.
Ok, cool.
Christian Graus wrote:
Dunno about wisdom, but I'd suggest the best approach is to learn how to do it all yourself, then use the appwizard for speed, knowing that if it screws up ( and it will ), you know how to fix it manually. There are no manly points for not using a time saving tool, but you should be be dependant on it.
Sounds like sound advice
Christian Graus wrote:
Also, often these things are defined across multiple files, so the CToolbar:: search should find them all.
Good call. Thanks again man!
-John
"Ask me about my vow of silence"
|
|
|
|
|
I have a seemingly small problem that is driving me insane. I can not seem to get to create an ImageList that is masked by another Bitmap (NOT just a single color). I didn't have too much trouble with this in Win32, but I can't seem to get it to work using MFC no matter what I try.
// What I've done is that I've created a Toolbar, like so:
m_wndToolBar.CreateEX ( this, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT, WS_CHILD | WS_VISIBLE /*etc*/ );
// Then, I tried to create the ImageList like so:
CImageList tbImgList;
CBitmap tbBMP_Color;
CBitmap tbBMP_MASK;
tbBMP_COLOR.LoadBitmap ( IDB_MAIN_TOOLBAR_I );
tbBMP_MASK.LoadBitmap ( IDB_MAIN_TOOLBAR_A );
tbImgList.Create ( 24, 24, ILC_COLOR24 | ILC_MASK, 0, 0 );
tbImgList.Add ( &tbBMP_COLOR, &tbBMP_MASK );
// Then I try to Set the ImageList like so:
m_wndToolBar.SetImageList ( tbImgList );
tbImgList.Detach();
tbBMP_COLOR.Detach();
tbBMP_MASK.Detach();
But for some reason it doesn't seem to work right. I'm using a 24-bit BMP for the color and an 8-bit BMP for the mask. I've also tried creating an HIMAGELIST instead and set it using SendMessage with a TB_SETIMAGELIST command, but that doesn't work either. The same scenario both ways masks just fine if I use a single color instead, like so:
tbImgList.Add ( &tbBMP_COLOR, RGB(255,0,255) );
Does anyone have any insight to this? I fear my sanity depends on it
-John
"Ask me about my vow of silence"
|
|
|
|
|
I meet the same error as you
But dont't know the reason !!
Who knows ??
It's me, code_cold
|
|
|
|
|
When I press ESC or ENTER key,the MediaPlayer will stop.
How can i disable ESC and ENTER in MediaPlayer OCX.
TNKS!
|
|
|
|
|
I'm trying to write a basic dialog program with MFC that loads a file up, lets you edit it then lets you save it so I can add a file to the games I've started making. Simple enough I thought It loads up the file fine, it lets you edit it to your hearts content in the control, but saving it it adds the characters ÿ to the first line of the file at the start :/ For the life of me I don't have a clue what its doing or why its doing it but I'm needing it to play nice and not do it
Using TRACE commands I've seen that its not adding the chars to the CString I'm using to hold all the data before its saved, its only when its saved that its added.
newDiz.Open("file_id.diz",CFile::modeCreate|CFile::modeReadWrite);
CArchive diz(&newDiz,CArchive::store);
diz << m_dizView;
diz.Close();
newDiz.Close();
Thats with newDiz being a CFile and diz obviously being a CArchive Using code like that before its worked in another program I wrote but in this one its being a pain in the bum.
Has anyone any idea why it would add these characters to the start of the file? Thanks for your help
|
|
|
|
|
Hi all,
Can anybody point out any site for window XP tips?
thanks
regards
/rsasalm
|
|
|
|
|
|
Hi,
i have some problems with getting info whether the given parent item is expanded or collapsed. My code is:
if (TVIS_EXPANDED == m_cMyTree.GetItemState(hMyTreeItem,TVIF_STATE))
else
but it seems not to work, and I cannot find info on this. Could you please help?
Thanks
R.
|
|
|
|
|
I might be wrong but have you tried.....
if (TVIS_EXPANDED == m_cMyTree.GetItemState(hMyTreeItem,TVIS_EXPANDED))
//Expanded
else
//not expanded
Or something like that, there is an axample in the MSDN Library that seems to indicate you need to change TVIF_STATE to TVIS_EXPANDED
JohnJ
http://www.rainbow-innov.co.uk
|
|
|
|
|
it is quite surprising for me but both function calls return the same results:
m_cTree.GetItemState(m_hType,TVIF_STATE);
m_cTree.GetItemState(m_hType,TVIS_EXPANDED);
the problem was that the return value contains bitwise information so the call must have been used in this way:
if (TVIS_EXPANDED & m_cTree.GetItemState(m_hType,TVIS_EXPANDED))
else
Thank you for pointing the above issue out.
R.
|
|
|
|
|
This is the map definitions:
typedef std::map<int, std::string> strmap;
strmap mPaths;
strmap::iterator miIterator;
First you do this:
miIterator = mPaths.find(index);
right? but what do you do next if you want to copy ther string into a char *?
thanks
|
|
|
|
|
You need to post more info on the map declaration:
Is is a map<string, int> or what?
You might find your answer in .second and .first
miIterator.first->c_str()
....
James
|
|
|
|
|
oh, it got lost due to html formatting, here it is:
typedef std::map<int, std::string> strmap;
strmap mPaths;
strmap::iterator miIterator;
if i then insert an item like this:
mPaths.insert(strmap::value_type(index, path));
how do i retrieve it again and copy it into a char array? first i do this right:?
miIterator = mPaths.find(index);
but what do i do next?
thanks in advance
|
|
|
|
|
miIterator->second is the string you're after.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Ohhhh, careful... I often see STL code that does stuff like this:
<br />
typedef std::vector< DWORD > VectDWORD;<br />
typedef std::vector< DWORD > VectDWORDIter;<br />
VectDWORD vecDWORD;<br />
VectDWORDIter iterDWORD;<br />
iterDWORD = vecDWORD.begin();<br />
<br />
FunctionThatTakesADWORDPointer( iterDWORD );<br />
Which works under some STL implementations, but may not really be correct: pointers can be treated like iterators under some situations, but the reverse? Stricter implementations will not let you do that (the stock one that comes with VC++ 6.0 will, however).
Peace!
-=- James.
"Some People Know How To Drive, Others Just Know How To Operate A Car."
[Get Check Favorites 1.4 Now!]
|
|
|
|
|
First of all, these typedefs are plain dumb. They make your code illegible.
Second of all, you can do the inserts much nicer like this:
mPaths[index] = path;
Thirdly, if you know for sure an index is in there, you can pull it out like this:
string s = mPaths[index];
beware - if you don't know for sure it is in there, you should use the method you've been using, the find and then ->second. Otherwise empty records will be entered into your map.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Where to get simple REAL HTTP/1.1-compatible proxy?
|
|
|
|
|
This is a point I've seen many people hold confusing ideas about. Essentially, if the other party falls down or there's a cut-off somewhere along the connection path, your connection end won't notice immediately. It is after some time-out has elapsed that the Winsock stack will decide the other end is not responsive and the connection will be aborted. To understand this, just consider that a TCP/IP connection is nothing but a couple of software entities that has settled upon some IP addresses and TCP ports to send and receive data to each other. The connection ends do not have the slightest idea of how the data actually travel from one side to the other, so they have to rely on timeout mechanisms to react to cutoffs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Got it. Tnx
|
|
|
|
|
I'm writing a UNICODE class that uses both the unsigned short as an integer value and wchar_t as a character. But since they are both the same data type, how can I tell the difference between them? For example:
int MyClass::operator>>(unsigned short value)
int MyClass::operator>>(wchar_t character)
The compiler complains that they are duplicate definitions of the same function. I thought of adding another parameter to one of them, but can't do that either because operators take only one parameter.
Any ideas?
|
|
|
|
|
wchar_t and unsigned short are the same thing in VC6
In VC7 you can define wchar_t as a native type but I am not able to find the documenetation link which specifies how to do it.
|
|
|
|
|
This is an unfortunate non-conformance to the standard by VC++. You'll have to workaround it somehow. For instance, by defining a disambiguating wrapper around wchar_t :
struct wchar_wrapper{
wchar_wrapper(wchar_t wc):wc(wc){}
operator wchar_t& (){return wc;}
operator wchar_t ()const{return wc;}
private:
wchar_t wc;
} Now you can declare your two operators like:
int MyClass::operator>>(unsigned short value);
int MyClass::operator>>(wchar_wrapper character); and use the second as folows:
wchar_t wc;
MyClass mc;
mc>>wchar_wrapper(wc);
PS: By the way operator >> is usually defined as returning a reference to the stream, like:
MyClass& MyClass::operator>>(unsigned short value);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|