|
There is an interesting behaviour, in that when I repaint something twice with the same string in GDI+ it becomes brighter, so I was wondering if the way that it paints the same string is not consistent.
I tried to test this by setting the background to black, and repainting the string with the background color, then repainting another string. If you look closely you can see the residue of the first DrawString(alot more aparent if you set background to brighter color).
Code Snippet:
<br />
Graphics g();<br />
SolidBrush b(Color(255, 0, 0, 255));<br />
SolidBrush bk(Color(255, 0, 0, 0));<br />
<br />
<br />
g.DrawString(A2CW("100"), -1, &font, pointF, &b);<br />
g.DrawString(A2CW("100"), -1, &font, pointF, &bk); <br />
g.DrawString(A2CW("101"), -1, &font, pointF, &b);<br />
So question is: Is this a feature, or am I missing something basic, or is it something so obvious that I should just rest, and think about it when I am up to speed again?
Side Note: Don't really consider this a VC++ question though posted here for a lack of a more suitable forum...
|
|
|
|
|
If you're drawing using smoothing, there may be some alpha blending going on, which would account for the brightening.
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
|
|
|
|
|
Went back and rechecked my assumptions, realized the default wasn't high quality. I take that to mean the algorithim used to fill doesn't always produce the same pixels.
Thanks for the input, that made me even more eager to look around tonight. Wish MSDN docs were more detailed on this subject.
|
|
|
|
|
I'm new to MFC, so forgive me if this is a dumb question, but I'm playing with the idea of creating my own Super-Toolbar class and I figured that the best way to go about it might be to derive a new class from "CRebar" or "CControlBar". However, if I go into the MFC ClassWizard and try to add a new class, neither of those classes are listed in the "Base Class".
What up with that?
-John
"Ask me about my vow of silence"
|
|
|
|
|
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
|
|
|
|
|