|
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.
|
|
|
|
|
What do you need exactly? user name? computer name? hardware profile? processes? folders? hardware?....
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 )
|
|
|
|
|
Thankq Hamid!!!
i have an application(i.e. an access control system).. im asked to use tcp/ip socket communication to interface. have to collect the information(device address where access violation takes place ,alarm id) 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)..
|
|
|
|
|
is there any written way to communicate or you have to create mechanism for this. could you please clear it
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
For the receiving side there is a code , which accepts the information.. i have to simply pass the value from the access control system service to the to the code...
can i use client side programming to get the info from service ?
|
|
|
|
|
it there is any documented way to retrieve code from service or you have to device your own for it...
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
yea there is a documented way.. if i give a command like this to the service"" <username password="******/>" i.e.="" mode="hold">
when a event occurs, then it ll send a command in the above said format.. i have to send the data from those command to another application .
i used client socket programming to send n receive the message., is there any way to get the data
wsprintf(Buffer, ""<username password="******/">", loopcount++);
iretval = send(c_socket, zBuffer, sizeof(zBuffer), 0);
if (retval == SOCKET_ERROR)
{
fprintf(stderr," send() failed: error %d.\n", WSAGetLastError());
WSACleanup();
return -1;
}
else
printf("send() is OK.\n");
printf(" Sent data \"%s\"\n", zBuffer);
modified on Tuesday, December 30, 2008 7:25 AM
|
|
|
|
|
Hi I have an application which protects and unprotects .doc file. If I protect file first it works fine but when I am unprotecting it with following code it unprotects properly but again if I am trying to protect it it gives error (File not in format i.e not structure storage file). Please let me know is anything wrong with following code.
COleVariant vFilename(csFile);
VARIANT vOptional;
vOptional.vt = VT_ERROR;
vOptional.scode = DISP_E_PARAMNOTFOUND;
int iStat = FILE_NOT_EXIST ;
// Now ole object specific processing
switch (iType)
{
case WINWORD:
{
pFile -> Dispatch -> AddRef();
_Document Doc;
Doc.AttachDispatch(pFile -> Dispatch);
// The actual save
Doc.SaveAs( vFilename,
&vOptional, // Format
&Optional, // LockComments
&Optional, // Password
&vOptional, // AddToRecentFiles
&vOptional, // WritePassword
&vOptional, // ReadOnlyRecommended
&vOptional, // EmbedTrueTypeFonts
&vOptional, // SaveNativePictureFormat
&vOptional, // SaveFormsData
&vOptional); // SaveAsAOCELetter
}
break;
}
Do I need to add / set some more variant variable in order to protect it in second time.
Thanks
SNI
SNI
|
|
|
|
|
<br />
...<br />
&vOptional,
&Optional,
&Optional,
&vOptional,
...<br />
Do you have two different variables vOptional and Optional?
|
|
|
|
|
no that is copy paste mistake. it it vOptional at each place.
SNI
|
|
|
|
|
|
I write a simple dll and inject to another process, i communicate with the target process by sending message via a named pipe. But now, the problem is that, although i can retrieve a top-level window of the target process,i will get no response if i send menu messages to it(the hwnd i retrieved, using EnumWindows, no matter i send the messages in the callback functions of EnumWindows or not, the results are the same). So, i think, the hwnd handle i retrieved was not the target hwnd handle witch was responsible to such activity.
But, how could i get the right hwnd to handle these menu messages?
Thanks
|
|
|
|
|
i will get no response if i send menu messages to it(the hwnd i retrieved, using EnumWindows, no matter i send the messages in the callback functions of EnumWindows or not, the results are the same)
Can you please post some code lines (sending menu messages) ?
|
|
|
|
|
I wrote enumwindows callback function like following:
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
DWORD procId;
GetWindowThreadProcessId(hwnd,&procId);
log_message("Main window search callback function is called.");
if(procId==(DWORD)lParam){
....the message would to be send here
return FALSE;
}
return TRUE;
}
I send the menu message in two ways:
1. HMENU trayMenu = GetMenu(hwnd);
if(trayMenu!=NULL){//usually equal to NULL, and according to the failure in method 2(send msg no response) i think i got the wrong hwnd handle
HMENU subMenu = GetSubMenu(trayMenu,0);
if(subMenu!=NULL){
DWORD menuItemId=GetMenuItemID(subMenu,0);
if(menuItemId!=-1)
SendMessage(hwnd,WM_COMMAND,menuItemId,0);
}
}
2.Because i can get the menu resource id, and, this code is implemented in a injected dll to the target process, so, there is a second method here:
HMENU trayMenu = LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDM_MENU));
if(trayMenu!=NULL){//successfully always
...the other code looks the same with the method 1, but the target process's specified routine will not be actived, because its no response.
|
|
|
|
|
Try to find out whether you are retrieving ID of the right menu item. Call GetMenuString() for that item and debug print it. If you send the message for menu item which consists of submenu, that won't help you (application doesn't display out the submenu as a result).
|
|
|
|
|
im sorry to reply so latter. i have gone to another city. and i know them problem now, i got the right menu, menuitems and menuIDs, but sent the menu message to a wrong hwnd. The program has more than one toplevel hwnd, so, i retieve all its top level hwnds and send menu message it them. then, when i got the right hwnd, the message would send successfully.
|
|
|
|
|