|
Call SetMenu(NULL) on your main frame, followed by DrawMenuBar() to update the screen
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
i have read what i could find and even looked at a few programs from here but i just cant figure out how to get them to change when i press one of them first what event do i use ? a keydown or a keyup or ??? i know VK_CAPITAL is for caps lock and VK_NUMLOCK is num lock and VK_SCROLL is scroll lock but thats about all i know on how to do it. i am very very
EDIT - I figured it out use PreTranslateMessage and
if (GetKeyState(VK_SCROLL) && 0x8000 == 0x8000)<br />
{<br />
m_bar.SetPaneText(3, "SCRL", TRUE);<br />
} works for me anyway
-- modified at 20:05 Tuesday 31st January, 2006
|
|
|
|
|
Yep, but use '&', not '&&'
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
im a noob what can i say
|
|
|
|
|
I am currently porting an MFC app from VC++ 6.0 to
VS 2005 (MFC8). So far I have noted the following MFC8 bugs.
01) AfxIsValidAddress
No longer properly validates the memory block:
In MFC6: (OK)
BOOL AFXAPI AfxIsValidAddress(const void* lp, UINT nBytes,
BOOL bReadWrite /* = TRUE */)
{
// simple version using Win-32 APIs for pointer validation.
return (lp != NULL && !IsBadReadPtr(lp, nBytes) &&
(!bReadWrite || !IsBadWritePtr((LPVOID)lp, nBytes)));
}
In MFC8: (bad)
BOOL AFXAPI AfxIsValidAddress(const void* p, UINT_PTR nBytes,
BOOL bReadWrite /* = TRUE */)
{
return ATL::AtlIsValidAddress(p, nBytes, bReadWrite);
}
// Verify that a pointer points to valid memory
inline BOOL AtlIsValidAddress(const void* p, size_t nBytes,
BOOL bReadWrite = TRUE)
{
(bReadWrite);
(nBytes);
return (p != NULL);
}
02) CFont::CreatePointFontIndirect
Calculates the font lfHeight incorrectly. In MFC6 it used simple division
to convert nPointSize to LOGFONT::lfHeight. In MFC8 it uses ::MulDiv which
rounds the result giving a different font size.
In MFC6: (OK)
BOOL CFont::CreatePointFontIndirect(const LOGFONT* lpLogFont, CDC* pDC)
{
....
pt.y = ::GetDeviceCaps(hDC, LOGPIXELSY), logFont.lfHeight;
pt.y /= 720; // truncates
In MFC8: (bad)
BOOL CFont::CreatePointFontIndirect(const LOGFONT* lpLogFont, CDC* pDC)
{
....
pt.y = ::MulDiv(::GetDeviceCaps(hDC, LOGPIXELSY), logFont.lfHeight, 720); // rounds
J. Yates
-- modified at 18:48 Tuesday 31st January, 2006
|
|
|
|
|
|
01) See here[^]. In non-debug builds, AfxIsValidAddress() only checks for non-null. Debug builds perform the full check.
02) This is a bug fix. MFC6 was doing the wrong thing (as mentioned previously).
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan
AfxIsValidAddress behaves the same (test for NULL only) on both debug and release builds. The bug is in the debug build which doesnt fully test the mem block.
J Yates
|
|
|
|
|
You've stepped through it in the debugger?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
|
Hi,
I am using Visual C++ version 6.0. I created a dialog based application using the MFC app wizard. Using the resource editor I placed a Tab Control in the dialog box and used the class wizard to give a variable name to the control. I can run the application and create the tab control with the tab text of my coice on the five tabs that I have. It seems I can select each tab. Where I am falling short is how to put other controls into each pane. I can only access and look at the properties for IDD_TAB1. How do I access the other panes and how do I put controls into the panes? If I try to put a control into IDD_TAB1 it is simply put "behind" the tab control as part of the dialog box.
Thanks,
Buck
|
|
|
|
|
This is where Windows .RC files let the team down - They don't support a hierarchy of windows so there is no direct way to place windows on (should I say in) the tab control. I create the tab contents programmatically and place it in the tab control. The contents is often a single control or perhaps a modeless dialog.
Steve
|
|
|
|
|
you can place the control in a separate dialog box.
then put the dialog box as a whole on the tab pane.
|
|
|
|
|
Didn't I say that? ("or perhaps a modeless dialog").
Steve
|
|
|
|
|
Sorry for being misplaced the reply,
actually I should reply to the questions but by mistake I did it to you.
Sorry.
|
|
|
|
|
|
|
Hi All,
I have discovered that when I convert a BSTR to both VT_I4 or VT_BOOL format
with VariantChangeType, a second thread appears in my application, and in
most cases simply sits in the background suspended. If I try to context
switch to that thread through the debugger and watch where it goes, my
connection to the debugger is lost and I must warmboot my device.
If I use VariantChangeType to convert from a long to a BSTR, this errent
thread does not appear.
One final note, when the program shuts down with this errent thread, an
exception is thrown, invalid access, probably because of that other thread.
Has anyone run into this, or is there any information on what is going on,
or how a developer is supposed to work around this?
Here is the code for this program to test this problem.
Thanks
-----------------------------------------------
#include <windows.h>
//C: Link in the library that contains the Variant functions.
#pragma comment(linker, "/defaultlib:oleaut32.lib")
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
//C: Initialize the variant object.
VARIANT v;
::VariantInit(&v);
//C: Test the different conversions independantly.
#ifdef BSTR_TEST
v.vt = VT_I4;
v.lVal = -1;
::VariantChangeType(&v, &v, 0, VT_BSTR);
BSTR bstr = v.bstrVal;
//C: No extra thread, PASSES.
#elif defined(LONG_TEST)
v.vt = VT_BSTR;
v.bstrVal = ::SysAllocString(L"-1");
::VariantChangeType(&v, &v, 0, VT_I4);
long l = v.lVal;
//C: At this point a second thread will have been created. FAILS
#else
v.vt = VT_BSTR;
v.bstrVal = ::SysAllocString(L"-1");
::VariantChangeType(&v, &v, 0, VT_BOOL);
VARIANT_BOOL b = v.boolVal;
//C: At this point a second thread will have been created. FAILS
#endif
//C: Free resources.
::VariantClear(&v);
return 0;
}
//C: If the second thread is created, when the program exits, an exception
is thrown.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi,
I am trying to the device manager refresh in win32.
How to do that. Thanks.
|
|
|
|
|
WM_DEVICECHANGE
The WM_DEVICECHANGE device message notifies an application of a change to the hardware configuration of a device or the computer.
A window receives this message through its WindowProc function.
HTH
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
But that's not I want. I am not plugging in any devices to watch for WM_DEVICECHANGE message. I just want to force a device manager refresh ( just as we do manually in the control panel-device manager-scan for hardware changes but programatically)
-- modified at 17:46 Tuesday 31st January, 2006
|
|
|
|
|
Yeah, so send it a WM_DEVICECHANGE message - it will catch it and think something has changed, so will refresh.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi!
Here's what I have:
HWND window = GetDlgItem(hDlg, IDC_TREE);
TVINSERTSTRUCT tvInsert;
tvInsert.item.mask = TVIF_TEXT;
tvInsert.item.pszText = _T("Parent");
HTREEITEM hTreeItem = (HTREEITEM)SendMessage(window,TVM_INSERTITEM,0,(LPARAM) (LPTVINSERTSTRUCT) &tvInsert);
SendMessage(window,TVM_INSERTITEM,0,(LPARAM) (LPTVINSERTSTRUCT) &tvInsert);
tvInsert.hParent = hTreeItem;
tvInsert.item.pszText = _T("Child");
SendMessage(window,TVM_INSERTITEM,0,(LPARAM) (LPTVINSERTSTRUCT) &tvInsert);
SendMessage(window,TVM_EXPAND, (WPARAM)(UINT)TVE_EXPAND,(LPARAM) (HTREEITEM) &hTreeItem);
BUuuuut.. the tree doesn't expand for some reason. I've tried collapsing it first then expanding, same thing, it just won't expand.
Kelly Ryan
|
|
|
|
|
KellyR wrote: SendMessage(window,TVM_EXPAND, (WPARAM)(UINT)TVE_EXPAND,(LPARAM) (HTREEITEM) &hTreeItem);
This line is wrong, it should read:
SendMessage(window, TVM_EXPAND, TVE_EXPAND, reinterpret_cast<LPARAM>(hTreeItem));
In particular you have a "&hTreeItem" where you should have just a "hTreeItem". I couldn't resist removing the old style C casts and replacing them with function style casts (which IMHO should be used in practically all new C++ code).
Steve
|
|
|
|
|
Great, that worked, thanks a lot.
Kelly Ryan
|
|
|
|
|