|
Do you have this problem on all projects or no and do you have open programs except VS?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
No
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Do you have latest Service pack installed? I found a similar thread[^] which says that its a bug in Visual Studio and the fix will be available in the latest service pack. So try installing the latest VS 2005 service pack from here[^], incase if you don't have it.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Close your project/solution and delete the NCB file associated with your project. Its a binary-tree containing the intelliSense data. Deleting it will force it to be rebuilt the next time you open the project. Hopefully that fixes your issue.
Best Wishes,
-David Delaune
|
|
|
|
|
Dear all
how to change the background color of dialog, i have done some code below, pls help me to check, however i couldn't change the background color after i picked the color. thanks.
void CMeiTengDlg::OnBnClickedChangebkcolor()
{
CColorDialog dlg;
if (dlg.DoModal() == IDOK)
COLORREF color=dlg.GetColor();
}
|
|
|
|
|
|
thanks, malli
i would like to use this way what i mentioned in the previous post. how can i achieve it? thanks a lot.
|
|
|
|
|
Delete the old brush and update the brush color by creating the new one
m_brush.CreateSolidBrush(RGB(255, 255, 255));
with the selected color.
|
|
|
|
|
thanks malli
don't understand well, i wanna change different color for different person, when someone click change background color. so i need a changbackground(COLORREF color), don't how to write down it. thanks. could you help me. thanks.
i tried your that way, just can change once.
|
|
|
|
|
I hope following code snippet will help you. I've not included the details in depth. Just try it out.
class CMeiTengDlg: public CDialog
{
...
protected:
CBrush m_objMyBrush;
...
};
BOOL CMyDlg::OnInitDialog()
{
...
m_objMyBrush.CreateSolidBrush(RGB(255, 255, 255));
...
}
BOOL CMyDlg::DistroyWindow()
{
m_objMyBrush.DeleteObject();
}
HBRUSH CAboutDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
return m_objMyBrush;
}
void CMeiTengDlg::OnBnClickedChangebkcolor()
{
CColorDialog dlg;
if (dlg.DoModal() == IDOK)
COLORREF color=dlg.GetColor();
changbackground(color);
}
void CMeiTengDlg::changbackground(COLORREF color)
{
m_objMyBrush.DeleteObject();
m_objMyBrush.CreateSolidBrush( color );
Invalidate(TRUE);
}
|
|
|
|
|
thanks Malli
i want to confirm i just wanna change my CMeiTengDlg background color, what mentioned above is CMyDlg, CAboutDlg, so i no need to add one class, right? so i followed your idea, but after compiled, one error is
c:\documents and settings\zhiyuan li\desktop\meiteng\meiteng\meitengdlg.cpp(163) : error C4716: 'CMeiTengDlg::DistroyWindow' : must return a value<br />
Build log was saved at "file://c:\Documents and Settings\ZhiYuan Li\Desktop\MeiTeng\MeiTeng\Debug\BuildLog.htm"<br />
MeiTeng - 1 error(s), 0 warning(s)
by the way,could i get your email, and keep in touch. thanks.
|
|
|
|
|
Sorry Zhiyuan16,
I forgot to replace the CMyDls with your dialog class name. And you should return value from DestroyWindow function. I had deleted rest of the code (and put ....) considering you'd put the required one. For details have a look at here[^]
|
|
|
|
|
thanks Malli
comiling had no problem, but still no color change of background after i chose different color.
where is problem, Malli? thanks
|
|
|
|
|
dear Malli
could you help me to check is it right below: thanks a lot
BOOL CMeiTengDlg::OnDestroyWindow()<br />
{<br />
m_objMyBrush.DeleteObject();<br />
return TRUE;<br />
}<br />
<br />
<br />
HBRUSH CMeiTengDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)<br />
{<br />
<br />
return m_objMyBrush;<br />
}<br />
<br />
void CMeiTengDlg::SetBackgroundColor(COLORREF color)<br />
{<br />
m_objMyBrush.DeleteObject(); <br />
m_objMyBrush.CreateSolidBrush( color ); <br />
<br />
Invalidate(TRUE);<br />
}<br />
<br />
void CMeiTengDlg::OnBnClickedChangebkcolor()<br />
{<br />
CColorDialog dlg;<br />
if (dlg.DoModal() == IDOK) <br />
color=dlg.GetColor(); <br />
SetBackgroundColor(color);<br />
}<br />
|
|
|
|
|
The above code worked for me (only 'color' variable I found missing). Do you have any overlapping control on your dialog ? And I think you should call
return CDialog::DestroyWindow();
in your dialog's DistroyWindow();
|
|
|
|
|
no other control..
Malli
could you check for me the following my dialog .h and .cpp files thanks.
CMeiTengDlg.h file
#pragma once
#include "afxwin.h"
class CMeiTengDlg : public CDialog
{
public:
CMeiTengDlg(CWnd* pParent = NULL);
void SetBackgroundColor(COLORREF color);
enum { IDD = IDD_MEITENG_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
protected:
HICON m_hIcon;
CBrush m_objMyBrush;
COLORREF color;
virtual BOOL OnInitDialog();
virtual BOOL OnDistroyWindow();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
DECLARE_MESSAGE_MAP()
public:
CComboBox m_pComboBox;
afx_msg void OnBnClickedChangebkcolor();
};
CMeiTengDlg.cpp file
#include "stdafx.h"
#include "MeiTeng.h"
#include "MeiTengDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
CMeiTengDlg::CMeiTengDlg(CWnd* pParent )
: CDialog(CMeiTengDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMeiTengDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_BITMAP, m_pComboBox);
}
BEGIN_MESSAGE_MAP(CMeiTengDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_ChangeBKColor, &CMeiTengDlg::OnBnClickedChangebkcolor)
END_MESSAGE_MAP()
BOOL CMeiTengDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_objMyBrush.CreateSolidBrush(RGB(255, 255, 255));
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);
SetIcon(m_hIcon, FALSE);
return TRUE;
}
void CMeiTengDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
void CMeiTengDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
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;
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR CMeiTengDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
BOOL CMeiTengDlg::OnDistroyWindow()
{
m_objMyBrush.DeleteObject();
return CDialog::DestroyWindow();
}
HBRUSH CMeiTengDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
return m_objMyBrush;
}
void CMeiTengDlg::SetBackgroundColor(COLORREF color)
{
m_objMyBrush.DeleteObject();
m_objMyBrush.CreateSolidBrush( color );
Invalidate(TRUE);
}
void CMeiTengDlg::OnBnClickedChangebkcolor()
{
CColorDialog dlg;
if (dlg.DoModal() == IDOK)
color=dlg.GetColor();
SetBackgroundColor(color);
}
|
|
|
|
|
ON_WM_CTLCOLOR() is missing in your message map. I hope you've added OnCtlColor handler manually.
|
|
|
|
|
thanks malli
now is ok. i have one more question here: in my dialog, i have several buttons, when i changed the background color, but dun chanaged the buttons' color, how can i can change the buttons' color after i choose different color. thanks
|
|
|
|
|
I think this[^] would help you.
|
|
|
|
|
thanks, malli
i have 3 radio buttons and one common button now, for 3 radio buttons, one is change background color, one is play music, last one is browse photoes, so when i check anyone radio button, and my that common button will show correspoding content what the radio button contains. thanks a lot.i searched online, but my pc and connection are slow, counldn't find. thanks.
|
|
|
|
|
Check this[^] one too.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Hi..
I'm supposed to get the information(when a event is trigered) from a application(service)running in a windows machine.. can some one please temme how to fetch it..
thanks in advance!!!
|
|
|
|
|
What exactly do you mean by "get the information" ? You looking for any "Data" communication between the processes or just an event notification ?
|
|
|
|
|
Thnks for the reply..
i ll tell u the exact scenario..
i have an application(i.e. an access control system).. im asked to use tcp/ip to collect the data(i.e.. address of the card reader, time and violation code) from the application when there is access violation... and after getting the instance of access violation, im supposed to pass the information to another application(written in c++) to take an action(record the event from a cctv where it is happening)..
|
|
|
|
|
I'm again confused ! Anyway, if you wanna to pass data across the process [i'm supposed to pass the information to another application(written in c++)] you can choose any of the Inter Process Communication mechanism[^]. And if you just wanna to sent an event notification (like a signaling kind of thing) you can use synchronization [^] object like Event.
|
|
|
|