|
Hi.
I have a rectangle of size:
CRect recTmp = CRect(0, 0, 200, 200);
In OnSize() message handler, I'd like to center text and other items inside the rectangle based on the new sizeof the window.
So, if the user resizes the window to CSize newSize(250, 250), the text and items new position will be (125, 125).
Anyways, I need a way to get the most current size of the view rectangle in either CPoint or CSize.
I have tried GetWindowOrg() and GetWindowExt(). I have not gotten any accurate size back from CDC.
Thanks,
Kuphryn
|
|
|
|
|
The new size is passed into OnSize() ; you can also use GetClientRect() .
And if words were wisdom, I'd be talking even more. The Offspring, I Choose
|
|
|
|
|
Nice!
I kept searching for help and looking all functions starting with "Get." I do not remember seeing GetClientRect().
Thanks.
Kuphryn
|
|
|
|
|
I want to "connect" two strings together. Like MFC's CMapStringToString, just both ways, and I'm not using MFC. There should be no limit to how many strings that can be stored. Btw, I've made my own little string-class, so only need a method for mapping them together. I also want the method to be fast, so iteration through a huge list of strings is not something I want to do.
Anyone got an elegant solution...?
Sprudling
|
|
|
|
|
Use a single list or array to store all the strings. Be sure each entry is unique. Then use one map to map the indices/pointers to each other in whatever combinations are appropriate.
This should be pretty fast, since the strings are only stored once, and string comparisons need only be made when new strings are added to the list.
And if words were wisdom, I'd be talking even more. The Offspring, I Choose
|
|
|
|
|
It would not be fast at all if it was a list.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
why is this?
And if words were wisdom, I'd be talking even more. The Offspring, I Choose
|
|
|
|
|
Because you'd have indices into a container to look up the actual strings, and list lookups require walking the list, they are slow compared to arrays which have instant lookup.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
!
Yes that would be slow. For a list i think you'd want to go with pointers.
And if words were wisdom, I'd be talking even more. The Offspring, I Choose
|
|
|
|
|
You could also look at the STL's pair<>.
|
|
|
|
|
You'll need a containter for strings and two maps - one for each 'way'. STL classes will be OK for that.
Aggregate these objects into one class, provide an interface - that's all.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I am using Chris' DIBSection wrapper for Win32 and WinCE. It is a great class, it's easy to use and very powerful.
But when I am using it, I have a question:
At first, I opened a 256-grey-scale bitmap file, using
m_pdib->Load("mybitmap.bmp");
Then in OnDraw(CDC *pDC)
{
m_pdib->Draw(pDC, pt, TRUE);
CPen redPen;
VERIFY(redPen.CreatePen(PS_SOLID, 1, RGB(255,0,0)));
CPen *pOldPen = pDC->SelectObject(&redPen);
pDC->Ellipse(pt.x, pt.y, pt.x+10, pt.y+10);
pDC->SelectObject(pOldPen);
}
The problem is: the bitmap file will be displayed correctly, but the red circle will not be displayed. I tried to use a white pen, but the circle couldn't be drawn either.
What did I do wrong?
Thank you very much for your help!
|
|
|
|
|
Are you sure values in pt are good ? Have you tried a hard coded constant to check ? Maybe pt is in screen co-ordinates, and needs ScreenToClient called on it ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Yeah, got it. The pt is too low to be displayed.
Thank you a lot, Christian!
|
|
|
|
|
just a newbie in c++ here
when i create a new mfc project, i add my buttons
and create a variable name for them then mapp anything
i need to, all fine, when i add a listbox or listview i get a
"undeclared identifier" for the List name, what am i doing wrong?
shotgun
|
|
|
|
|
For some reason, the variable is not in your header file.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
[Updated...]
On VC++ 6.something, and building on Win2000...
Should contextual menus have mnemonics ( display them ? ) ?
This is what I do, and doesn't seems to show mnemonics on contextual menus... :
...
CMenu menuTemp;
VERIFY(menuTemp.LoadMenu(IDM_MY_MENU) );
CMenu* pPopup = menuTemp.GetSubMenu(0);
ASSERT(pPopup != NULL);
VERIFY( pPopup->TrackPopupMenu(TPM_RIGHTBUTTON,pt.x,pt.y, AfxGetMainWnd()) );
...
and goes to to the ON_UPDATE_COMMAND_UI handler ...
void CMyClass::OnUpdateMenuItem(CCmdUI* pCmdUI )
{
pCmdUI->Enable( SomeCheck() );
CString s = AddAccelerator(pCmdUI, 0)
pCmdUI->SetText( s );
}
the resources have all the "&" at the right places ... and the handler is also used for the main app. menu ( and the mnemonics are displayed ! ).
Thanks.
Max
|
|
|
|
|
|
This is really worst than I expected, I've been looking at this for the past hour and this is what I found :
In my understanding of MFC and Win32 things, the different menus, don't show the "_" ( mnemonics ) when used with the mouse, but when the user press the "alt" key ( of "F10" ) the menus get into a keyboard navigation mode, and Windows will show the "_".
Me, just frustrated !
Max.
|
|
|
|
|
This is a new "feature" of Win2k & up. You can disable it under Display Properties->Effects.
And if words were wisdom, I'd be talking even more. The Offspring, I Choose
|
|
|
|
|
Shog9 wrote:
You can disable it under Display Properties->Effects
Ok, I get it ... Thanks....
M.
|
|
|
|
|
Hi All,
I'm working on some socket classes, and I would like to able to spy on the activity of a windows socket in IE. Specifically, I'd like to be able to intercept the buffer passed to the recv function.
Is there some sort of utility around for this? I found a sharewaer program, but it was too crippled to be useful.
Thanks,
Aaron
|
|
|
|
|
Matt Pietrek did something similiar in Sept'97 issue of MSJ. It may be in MSDN on your harddisk.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Use a packet sniffer.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|