|
C:\BKView.cpp(195) : error C2166: l-value specifies const object The error says it all! You're defining a pointer to a const MENUINFO and trying to fill it: two errors here, the const -ness thing prevents you from changing the contents and you haven't allocated any space for lpcmi . What you surely will want to do is the following:
HMENU m_hMenu = submenu->GetSafeHmenu();
MENUINFO mi;
mi.cbSize=sizeof(MENUINFO);
mi.dwStyle = MNS_NOTIFYBYPOS;
SetMenuInfo(m_hMenu, &mi);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yikes! I am sooooo blind! Thanks!
I modified my post above to include the caution I got about WInver....do I need to worry about that? You said it wont work on NT4. Is that right? I need it to work on NT4, but not worried about win95...
Appreciate your help,
ns
|
|
|
|
|
Well, as for the warning it is sweet from Microsoft that they inform you about the convenience of downloading the latest SDK. If you have time I'd recommend you to do it, altough in this particular simple case you won't probably need it.
The NT4 problem seems unsovable: docs are very precise in stating that MENUINFO functionality is not available in NT 4.0.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
From the MSDN I found the requirements too...so I wonder how people handled getting the index of the menu item and running an index specific handler (not ID specific) on NT.
Requirements
Windows NT/2000/XP: Included in Windows 2000 and later.
Windows 95/98/Me: Included in Windows 98 and later.
Header: Declared in Winuser.h; include Windows.h.
BTW, its happy now since the constantness issue is resolved (and I still think they shouldnt have said LPCMENUINFO in the argument for SetMenuInfo..I guess they mean they will treat it as constant after it goes in....do you agree? . So before we pass it in , we have to do it like you showed me, and pass the address...
Appreciate your help,
ns
|
|
|
|
|
BTW, its happy now since the constantness issue is resolved (and I still think they shouldnt have said LPCMENUINFO in the argument for SetMenuInfo..I guess they mean they will treat it as constant after it goes in....do you agree? . So before we pass it in , we have to do it like you showed me, and pass the address...
This idiom may be difficult to understand at first, but it is most usual: Win32 (and almost any other library you can think of) is crowded with examples similar to this with regard to the const pointer issue. After all, the idiom seems more natural if you consider that the function invoked can do little with a const pointer except reading its contents, so it makes sense that the caller be responsible of filling them.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
My next effort is putting in the message map entries for my submenu handler for WM_MENUCOMMAND...I'll be back with more questions I am sure.
Do you think I am correct in understanding that if I give SetMenuInfo a partiicular handle, only that menu will be NOTIFYBYPOS, and my other menu items will be running the usual COMMAND handlers? I havent tested that yet either....so stuff I added under File, View etc retains its normal behavior...
Appreciate your help,
ns
|
|
|
|
|
Okay. My other menu stuff seems to be normal, and I havent yet messgagemapped the one I setMenuInfo for.
Appreciate your help,
ns
|
|
|
|
|
What SDK do I want? Do I want the SDK for Microsoft Platform SDK in the download section? Or do I need a Visual Studio 6 SDK (is there even such a thing? ) I didnt see a VS SDK link, but theres stuff for .NET SDK. But I'm using VS6, and Win2K.
I looked up SDK in MSDN but I couldnt decide whose SDK I need.
Appreciate your help,
ns
|
|
|
|
|
|
I'm working on an MDI project and I want it to be possible to open more than one instance of a given document. How do I force OpenDocumentFile() to create a new doc/view even if a document has already been opened from the given file?
|
|
|
|
|
Take a look at the CMultiDocTemplate class. When a document file is opened it checks in this calss to see whether the file is already open. You will need to modify/override this behaviour.
Roger Allen
Sonork 100.10016
WHats brown and sticky?
A stick or some smelly stuff!
|
|
|
|
|
Thank you, Roger, but... can you be more specific? Which functions should I override?
|
|
|
|
|
Please help.
I created a dialog app that contains a picture control which acts like a button.
The picture control (IDC_MODEL_COLOR) will bring up the common dialog CColorDialog and allows the user to select an RGB color. This color will then repaint the picture control to show the user the color that was selected.
My problem is in initialization and the odd case of toggling focus between my app and another window on the desktop.
Initialization Problem:
The correct color of IDC_MODEL_COLOR is not displayed when my dialog appears.
(See code for constructor and OnInitDialog() below and the visual at
http://www.dlowracing.org/mmedia/Dialog_Black.gif 3kb
http://www.dlowracing.org/mmedia/Dialog_Red.gif 3kb -- what should be)
Toggle Problem:
When I change focus between my dialog app and another window on the screen, without moving either window, the picture control is not repainted. For example, if part of
IDC_MODEL_COLOR is covered by another window and I toggle focus between the two (Without moving either window), the part that was covered is not repainted.
(See http://www.dlowracing.org/mmedia/CColorDialog_.gif 9kb)
Below is the code that supports my dialog based app.
Thank you for your help.
Johnny
/////////////////////////////////////////////////////////////////////////////
// CColorTestDlg dialog --- ColorTestDlg.h
class CColorTestDlg : public CDialog
{
// Construction
public:
CColorTestDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CColorTestDlg)
enum { IDD = IDD_COLORTEST_DIALOG };
CEdit m_edit_red;
CEdit m_edit_green;
CEdit m_edit_blue;
int m_red;
int m_green;
int m_blue;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CColorTestDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
public:
void SetModelColorSwatch(COLORREF rgbColor);
private:
COLORREF m_ModelColor;
CRect m_ModelColorSwatch;
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CColorTestDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnModelColor();
afx_msg void OnKillFocusBlue();
afx_msg void OnKillFocusGreen();
afx_msg void OnKillFocusRed();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
// CColorTestDlg dialog --- ColorTestDlg.cpp
CColorTestDlg::CColorTestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CColorTestDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CColorTestDlg)
m_red = 255;
m_green = 0;
m_blue = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
// IDC_MODEL_COLOR properties: Rectangle, Black, Sunken, Notify
m_ModelColor = RGB(255,0,0); // Initialize to RED
}
void CColorTestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CColorTestDlg)
DDX_Control(pDX, IDC_EDIT_RED, m_edit_red);
DDX_Control(pDX, IDC_EDIT_GREEN, m_edit_green);
DDX_Control(pDX, IDC_EDIT_BLUE, m_edit_blue);
DDX_Text(pDX, IDC_EDIT_BLUE, m_blue);
DDX_Text(pDX, IDC_EDIT_GREEN, m_green);
DDX_Text(pDX, IDC_EDIT_RED, m_red);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CColorTestDlg, CDialog)
//{{AFX_MSG_MAP(CColorTestDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_MODEL_COLOR, OnModelColor)
ON_EN_KILLFOCUS(IDC_EDIT_BLUE, OnKillFocusBlue)
ON_EN_KILLFOCUS(IDC_EDIT_GREEN, OnKillFocusGreen)
ON_EN_KILLFOCUS(IDC_EDIT_RED, OnKillFocusRed)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CColorTestDlg message handlers
BOOL CColorTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
// Calculate true location of the color swatch
// Get a pointer to CWnd
CWnd* pModelColor = GetDlgItem(IDC_MODEL_COLOR);
// Find its location on screen
pModelColor->GetWindowRect(&m_ModelColorSwatch);
// Store client coordinates
ScreenToClient(&m_ModelColorSwatch);
m_ModelColorSwatch.DeflateRect(2, 2, 1, 1);
return TRUE;
}
void CColorTestDlg::OnPaint()
{
SetModelColorSwatch(m_ModelColor);
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
void CColorTestDlg::OnModelColor()
{
CColorDialog dlg(m_ModelColor, CC_FULLOPEN);
if (dlg.DoModal() == IDOK)
{
// update the parent's color variables
m_ModelColor = dlg.GetColor();
CBrush swatch;
swatch.CreateSolidBrush(m_ModelColor);
CClientDC dc(this);
dc.FillRect(&m_ModelColorSwatch, &swatch);
}
}
// update the color swatch with the RGB color value
void CColorTestDlg::SetModelColorSwatch(COLORREF rgbColor)
{
CBrush swatch;
swatch.CreateSolidBrush(rgbColor);
CClientDC dc(this);
dc.FillRect(&m_ModelColorSwatch, &swatch);
}
|
|
|
|
|
sorry for the long post.
The references are to visuals that would help explain my situation - CColorDialog_.gif (or CColorDialog.gif same thing) is an animated gif
that shows effects of the Toggle Problem i'm experiencing.)
Thanks again for any help.
Johnny
|
|
|
|
|
Hello everbody:
I was wondering if it is possible to have more than one line in the string that is going to be displayed in a tool tip? I gave it a try with the following code, but is displayed all in one line and there is a small square in between the two strings that I want to display:
<br />
CString displayLine;<br />
CString idString;<br />
idString.LoadString(IDS_TT_DCSRAW);<br />
displayLine.Format("%s\nHi Res", idString);<br />
.<br />
.<br />
.<br />
m_ToolTip->AddTool(this, (LPCTSTR)displayLine,rFileTypeCoord, 1);
Is this a Tool Tip attribute that I have to set? Is there another way to put the new line character? Any answer is more than welcome.
Best regards,
Luis E. Cuadrado
)
|
|
|
|
|
No it is not possible that I can see. I've only seen 1 line, albeit some long ones, but when ever I've added the "\n" I only get the text that comes after the "\n". for example:
if the tooltip is "I am having\nsome difficulties"
what you see on the screen is "some difficulties"
There may be some funky trick to do it, but I haven't yet found one.
Hope this helps!
Dan Willis
|
|
|
|
|
|
I found a way! Where you create the CToolTipCtrl and and you call the Create() method, you had the following line:
m_ToolTip->SendMessage( TTM_SETMAXTIPWIDTH, 0, 300);
Then in the AddTool() method, you can put \n's and it will add a new line to the tool tip. The code looks pretty much like this:
if ( m_ToolTip == NULL ) <br />
{ <br />
m_ToolTip = new CToolTipCtrl; <br />
m_ToolTip->Create(this); <br />
m_ToolTip->SendMessage( TTM_SETMAXTIPWIDTH, 0, 300); <br />
}<br />
m_ToolTip->AddTool(this, "One line\nSecond Line\nThird line"); <br />
m_ToolTip->Activate(TRUE);
I did this and it worked.
Best regards,
Luis E. Cuadrado
)
|
|
|
|
|
Hi All,
I'm confused with this. I'm using VS C++ 6.0 w/MFC in an MDI app. I've created a new class called CCustomToolBar that is inherited from CToolBar.
Problem is this:
When I add the ON_COMMAND_UI message handler to the CCustomToolBar, the Onupdatebutton gets called a bunch of times (I still don't know why, any answers?). But the ON_COMMAND message NEVER gets sent to the CCustomToolBar's message handler.
The funny thing is, if I add the message handlers to the MainFrame class, the messages are received just fine. I have no idea why and since I'm going to be dealing with 10-14 toolbars, I really need to ensure that the messages goto the right places.
My questions are:
1) What am I doing wrong?
2) What am I missing?
3) Why does the ON_COMMAND_UI message handler get called so often?
Any insight on the matter is GREATLY apreciated
Dan Willis
|
|
|
|
|
I wanted to create an application in VC++ (which ia dialog based). This application should display a dialog in which the user is supposed to enter his login and Password..which is not provided does not allow him to work on a windows PC at all....It blocks the start button ...And also he is not allowed to use (ALT + TAB) ..I wnated to know how to go about this?
Clemence D
|
|
|
|
|
I need to write a program that will remove one global security group and will replace it with another security group. This program will be ran on each machine locally Please help
|
|
|
|
|
Did you try Network Management Functions?
try:
NetGroupAdd
NetGroupAddUser
NetGroupDel
NetGroupDelUser
NetGroupEnum
NetGroupGetInfo
NetGroupGetUsers
NetGroupSetInfo
NetGroupSetUsers
A. Riazi
|
|
|
|
|
Yes but every time I try to complie the project I get the following linking errors
Linking...
nafxcw.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in libcp.lib(delop.obj)
groupremoval.obj : error LNK2001: unresolved external symbol _NetApiBufferFree@4
groupremoval.obj : error LNK2001: unresolved external symbol _NetGetDCName@12
groupremoval.obj : error LNK2001: unresolved external symbol _NetUserAdd@16
groupremoval.obj : error LNK2001: unresolved external symbol _NetUserDel@8
groupremoval.obj : error LNK2001: unresolved external symbol _NetUserSetInfo@20
groupremoval.obj : error LNK2001: unresolved external symbol _NetUserChangePassword@16
groupremoval.obj : error LNK2001: unresolved external symbol _NetUserGetInfo@16
groupremoval.obj : error LNK2001: unresolved external symbol _NetQueryDisplayInformation@28
groupremoval.obj : error LNK2001: unresolved external symbol _NetUserEnum@32
groupremoval.obj : error LNK2001: unresolved external symbol _NetGroupAdd@16
groupremoval.obj : error LNK2001: unresolved external symbol _NetGroupAddUser@12
groupremoval.obj : error LNK2001: unresolved external symbol _NetGroupDelUser@12
groupremoval.obj : error LNK2001: unresolved external symbol _NetGroupDel@8
groupremoval.obj : error LNK2001: unresolved external symbol _NetGroupEnum@28
groupremoval.obj : error LNK2001: unresolved external symbol _NetGroupGetUsers@32
groupremoval.obj : error LNK2001: unresolved external symbol _NetLocalGroupAdd@16
groupremoval.obj : error LNK2001: unresolved external symbol _NetLocalGroupAddMembers@20
groupremoval.obj : error LNK2001: unresolved external symbol _NetLocalGroupDelMembers@20
groupremoval.obj : error LNK2001: unresolved external symbol _NetLocalGroupDel@8
groupremoval.obj : error LNK2001: unresolved external symbol _NetLocalGroupEnum@28
groupremoval.obj : error LNK2001: unresolved external symbol _NetLocalGroupGetMembers@32
nafxcw.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcw.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Release/groupremoval.exe : fatal error LNK1120: 23 unresolved externals
Error executing link.exe.
groupremoval.exe - 25 error(s), 0 warning(s)
|
|
|
|
|
Do you link with the Netapi32.lib file and including Lm.h as MSDN Library says?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
I want to write an application to monitor our company employees. In other hand, monitoring visited sites by users, their activity on internet and so on.
Does anybody have any idea to start this project? Where can I find some documents, APIs, Classes and ...?
Thanks, A. Riazi
|
|
|
|