|
harropj wrote:
My understanding is that to add any colour to a button you need to make it owner draw and handle the CTLCOLOR_BTN message.
Not entirely so. You can use the BS_PUSHBUTTON style to indicate how the button responds to a mouse click. However, you can also override the WM_PAINT message handler to modify the way the button is drawn.
This approach is somewhat of a semi-owner drawn button, where Windows OS default behaviour is used to the maximum extent, and only where required, the default behaviour is overridden.
Unfortunately I don't know if there's source code available for Calc.exe. In Windows 2003, I also believe that the calculator is implemented by using C# or other .Net Framework language (such as C++/CLI). The .Net Framework offers many, many improvements over standard Windows or MFC approach procedures. When looking at the .Net Documentation, you can see that there is a Button class in System.Windows.Forms namespace. This class has a property called ForeColor that depicts the button's text color.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
i have written an application which i start at boot time. now, when the system is shut down, i don't do anything explicitly in my application. i know, when the system goes down, it sends WM_QUERYENDSESSION message and when all the application returns a non-zero value, it sends a WM_ENDSESSION message. Now, how do i handle this message in my dailog based application. I need to handle this message coz i need to change a registry entry when the system shuts down. the classwizard does not show the handling of such message.
pliz help.
|
|
|
|
|
You'll have to manually add the ON_WM_ENDSESSION() entry to the message map and add a void OnEndSession(BOOL bEnding) function to handle the message.
Michael
CP Blog [^]
|
|
|
|
|
hi Michael,
i manually added the ON_WM_ENDSESSION() and in the OnEndSession(BOOL bEnding) function did the necessary regitry changes. Now, the application responds to shutdown. but it also responds when i log off. i do not want my application to make any registry changes when i just log off. how do i differentiate between 'SHUT DOWN' and 'LOG OFF'. should i handle WM_QUERYENDSESSION messge instead of WM_ENDSESSION.
|
|
|
|
|
If you want to detect whether the session is ending due to a Log-off then you need to handle the WM_QUERYENDSESSION message. The lParam value of the message contains the info of the session end state.
Michael
CP Blog [^]
|
|
|
|
|
The problem here is that you can not use the functions OnEndSession and OnQueryEndSession as they do not get the lParam passed through from the MFC message handler.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
This is not that straight forward. The flags that are sent are in the LPARAM of the message but are not directly accessable from the OnEndSession virtual function.
If you override the MFC message handler you can check the LPARAM for ENDSESSION_LOGOFF.
LRESULT CALLBACK CMainFrame::NewMsgHandlerFn(HWND hWnd,UINT uMsg,WPARAM wParam, LPARAM lParam)
{
if( uMsg == WM_ENDSESSION )
{
if( lParam & ENDSESSION_LOGOFF )
{
return true;
}
}
return CallWindowProc(s_pOldMsgHandler,hWnd,uMsg,wParam,lParam);
}
I hope that helps.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Its been a while since I did any MFC but can't you just
ON_MESSAGE(WM_ENDSESSION, OnMyEndSession)
and
LRESULT OnMyEndSession(WPARAM wParam, LPARAM lParam)
{
return 1;
}
Michael
CP Blog [^]
|
|
|
|
|
That is a very good point. I seem to have over complicated the situation.
Aw, well at least it is an exercise in subclassing.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Antony M Kancidrowski wrote:
That is a very good point. I seem to have over complicated the situation.
You know me, if there is an quick, easy way to do something I'll use it. Subclassing is just too much like hard-work. Thats why I use C# now, less work to do.
Michael
CP Blog [^]
|
|
|
|
|
WOW!
both the solution worked
but i decide to go with the easier solution...
i handle WM_ENDSESSION message on log-off and shut down seperately.
well, thnx all
|
|
|
|
|
Tried to incorporate the function suggested by u.
there is a compile error in
CallWindowProc(s_pOldMsgHandler,hWnd,uMsg,wParam,lParam);
Error:::'s_pOldMsgHandler':undeclared identifier
will u please elaborate the callback function and also the idenfifier 's_pOldMsgHandler'
|
|
|
|
|
Sorry,
s_pOldMsghandler is defined.
static PMSGHANDLERFN s_pOldMsgHandler;
then in the .cpp
PMSGHANDLERFN CMainFrame::s_pOldMsgHandler;
Subclass the message handler in a Subclass function
void CMainFrame::Subclass()
{
:
s_pOldMsgHandler = (PMSGHANDLERFN)SetWindowLong(m_hWnd,GWL_WNDPROC,(LONG)NewMsgHandlerFn);
:
}
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
HI~
Is there any function in eVC++ which can pass some parameters to a running C# program?
"CreateProcess" can pass some parameters as a argument when a process start. However, how about the process is running?
Thanks~
|
|
|
|
|
If you look for IPC and/or Interprocess Communication this should help you out.
Sorry forgot to say: If you look in the eVC++ help that is!
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
I don`t know if this is THE way to pass data, but in my case I`
use shared memory... And protect access by a global mutex
Check out the funcs
CreateFileMapping to create the shared mem portion and
MapViewOfFile to get access to the mem portion, and use a named
mutex to prevent read-write errors between apps.
`Hope this helps,
Davy
|
|
|
|
|
Hi. I try to connect to a Microsoft SQL database using Ole Db - IRowSet interface. This works, but I can't bind it to a grid control (I use Microsoft Datagrid control).
I have:
IRowset* pRowset;
DDX_Control(pDX, IDC_DATAGRID1, m_grid);
........................................
I try to bind by
m_grid.SetRefDataSource((LPUNKNOWN)pRowset);
but it raises an exception : Type mismatch.
Well, I tried - I suppose . Could someone help me?
Gabi
|
|
|
|
|
hi all,
i have converted a Form view based application to cview now im facing an error when i run the application the error is "failed to create empty document". please do reply . thanks in advance
Haseeb Ahmed
|
|
|
|
|
It could be one of many things. The only way to succesfully solve these problems is to put a breakpoint at the beginning on the InitInstance method and step through the code until the error is thrown.
Michael
CP Blog [^]
|
|
|
|
|
i have a log file which is a MS-access database. i have the following problem:-
1. wat is the name of the MS-access driver so that i can package it with my application and it can run on any machine irrespective of whether that machine has MS-access installed or not?
2. my log size increases very quickly. i want to rotate the log(i.e, something like syslog in Linux which rotates log weekely)
wat should i do?
|
|
|
|
|
Anonymous wrote:
wat is the name of the MS-access driver...
Look at the Drivers tab on the ODBC Data Source Administrator dialog. It shows:
Microsoft Access Driver (*.mdb)
Anonymous wrote:
2. my log size increases very quickly. i want to rotate the log...
Add a date/time field to the table, and index it. Periodically run through the rows, deleting those that have "expired."
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I dont know much but... "Ms Access uses JET DATABASE DRIVER". You use ODBC which acts as an interface between your application and JET
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
I have developed activex control in MFC. It is text control with additional features.
I am testing it in VB.
Design time properties are getting set.
When I try to set the properties at run time and execute the application I am getting the following error.
If I try to access text property
error is as follows
Method text of object '_DoleEdit' failed
|
|
|
|
|
i have a function IsAdministrator() which tells me whether i the administrator or not(i.e, i have administrative rights). Now i want to include this code in my dialog based application so that only the administrator can run the application. I tried to include it in the InitDialog() but it did not work. Should i put it in the constructor?
|
|
|
|
|