|
For MFC programmers, an important distinction is whether a DLL is an MFC Extension DLL or not. It is certainly true that a regular DLL can be C++ specific to the extent of being incompatible with other languages such as Visual Basic, but what is important is that MFC classes can be shared between EXEs and DLLs only when the DLL is an MFC Extension DLL. See MFC "TN011: Using MFC as Part of a DLL" and "TN033: DLL Version of MFC".
|
|
|
|
|
Howdy Folks!
Is there a way to redirect my dialog to get its own system colors somewhere else in the registry? I know how to write the colors into the registry, but I want to know if there is a way to make my application only to look for the registry colors elsewhere.
I would also like to know how to change the color of the Menu in my MFC application, I have tried to add code to my OnDrawItem when its called by the Menu, but I don't know if I use the right commands (I'm no ACE at C++ so far, hehe, learning fast though)
Another "thingie", hmm... I have set my dialogs background with the SetDialogBkColor() but it seems like the (what do you call it, hmm... border, frame, nm) the outer edge of the window is still taking the colors from the system. How do I paint that area?
Then there's the problem with my controls. I have a Slider that still takes the system color in it's "slider-path" and on the "slider-knob" (or whatever you call these, hehe). Where can I set those colors?
Then theres my ComboBox wich has that little arrow, (you know, the one you klick on to bring down the ComboBox's menu) I want to set its color too =)
If you happen to know how I can "redirect-the-registry-thingie" there's no hurry for the rest of the answers, but I'd like to know the other ways to do it too =)
Thats all Folks, thanks for redin'!
/Fredrik
|
|
|
|
|
Before you go messing around with color in your dialog box, you should go to this web page:
http://www.iarchitect.com/mshame.htm
It talks about all of the evils of user-interface design.
Sure, you can setup your own registry keys for colors, but at that point, they are no longer considered "system" colors.
In order to paint the 3-d portions of your dialogs, you'll probably have to override the OnPaint() function and do *all* the drawing yourself.
As far as painting controls, the same thing applies, only you'll have to subclass the controls and override their OnPaint code too. Don't forget to make them owner-drawn in your dialogs too.
Are you sure all of this is worth the effort?
If you want to make your dialogs look more vibrant with less work, use Visual Basic...
|
|
|
|
|
Hi again!
Thanks for the info John, and the site you gave me was good. I do need to change the colors though, even though it's sort of against my will, hehe. How do I direct the registry so that I can make my application get its own colors (true that they wouldn't be "system" colors no more, like you said, good point). I want the colors of the other applications running to still use the real system colors, and only my application to use the "fake" or call them "virtual" system colors. =)
I would guess that this way would be the best since it would give me a better view of the colors than to override OnPaint code for all the controls.
Thanks again,
/Fredrik
|
|
|
|
|
I'd probably setup registry keys (as strings) that contained the three color values used to instantiate a CCOLORREF value.
DlgBkgrnd="0,0,0"
DlgButtonFace="1,1,1"
etc...
I would also probably set these up under the HKEY_CURRENT_USER key if you anticipate more than one user using the software on a given machine. This way, each user's settings will be unique to that user (when they log on to the machine).
I believe there's a couple of registry classes here on Code Project.
|
|
|
|
|
Hi!
I know how to do what you just described, but what I need to know is how to override the system colors for my dialog window only. I have no clue how to make my application to actually look for the colors elsewhere than at the place where windows has it's system colors. I know how to create the keys and set upp the palette values I need in my dialog, but when I have made my own palette in the registry, I have no clue how to make the dialog to actually be pointed to my own defined palette in the registry rather than the one it is pointing at by default (the system colors).
Thanks a bunch,
/Fredrik
|
|
|
|
|
IS there a way to lauch an console EXE using ShellExecute or another API that will allow the output to be piped to a control CEditCtrl or CListCtrl?
|
|
|
|
|
See: http://msdn.microsoft.com/library/psdk/winbase/prothred_4uus.htm
I think that the CodeGuru web site has an example and probably this web site does too but I have not looked around in this web site much yet.
|
|
|
|
|
How do you change the foreground color of a button?
|
|
|
|
|
I am far from good at C++ but this is what I did after looking around on diffrnt sites, hope it helps/works =)
First: I used MFC to make the button in my dialog, then I chose Properties with left mouse button on the button and set the button to ownerdrawn. Then use Classwizard to add the WM_DrawItem (Is it called a listener? Nm...hehe) to your dialog window. Then add the following code, with a few changes:
void CAboutDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpdis) // (Change the name CAbotDlg to your Dialogs name (Classwizar should do this for you though))
{
CBrush myBrush;
CBrush m_brHollow;
myBrush.CreateSolidBrush(RGB(178,196,213)); //Change the RGB color to what you want the color of the the button to be
m_brHollow.CreateStockObject(NULL_BRUSH);
const UINT& nAction = lpdis->itemAction;
// Full redraw or selected (up/down) state changed
CWnd* pCtl = CWnd::FromHandle(lpdis->hwndItem);
CString sText;
pCtl->GetWindowText(sText); // button text
CRect rc;
pCtl->GetWindowRect(&rc); // window rectangle..
pCtl->ScreenToClient(&rc); // ..client rectangle
if (lpdis->itemState & ODS_SELECTED) // button is down:
rc += CPoint(1,1); // shift southeast
CDC* pDC = CDC::FromHandle(lpdis->hDC);
// painting the background
CBrush* pOldBrush = pDC->SelectObject(&myBrush);
pDC->PatBlt(0, 0, rc.Width(), rc.Height(), PATCOPY);
pOldBrush = pDC->SelectObject(pOldBrush);
if (lpdis->CtlType==ODT_BUTTON)
{
// Draw button border using COLOR_BTNTEXT
CBrush* pOldBrush = pDC->SelectObject(&m_brHollow);
CPen pen(PS_SOLID, 2, GetSysColor(COLOR_BTNTEXT));
CPen* pOldPen = pDC->SelectObject(&pen);
pDC->Rectangle(&rc); // Draw rectangle
// Draw button text
pDC->SetTextColor(GetSysColor(COLOR_BTNTEXT));
pDC->DrawText(sText,&rc,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
pDC->SelectObject(pOldBrush);
pDC->SelectObject(pOldPen);
} else {
// Note: assumes static icon!
pDC->DrawIcon(0, 0, AfxGetApp()->LoadIcon(IDR_MAINFRAME)); //I'll be honest to tell you I don't fully know what this line does =)
}
}
Hope that helps, I'll be checking in here later for questions/remarks etc...
/Fredrik
|
|
|
|
|
Thanks for the help, I had gotten a solution similar to this from another site, nice to know we all think alike. I am actually going to use the colorbtn class that is posted on here under the button control on the front page for this site. Seems like the easiest way to go. I appreciate your help, let me know if you ever need anything.
|
|
|
|
|
Visual C++ 6.0
MFC
Does anyone have any code for putting a bitmap into a status bar pane?
Many thanks in advance.
|
|
|
|
|
I want to create an exe file from another exe file.
There is one exe file, which when run, creates another exe
file. The first exe file remains intact. How this could
be done?
Can anybody help me in this regard?
Thanks
|
|
|
|
|
The Win32 Command to spawn another exe is CreateProcess(...). This will start another EXE and leave the first EXE running. is this what you are looking for?
|
|
|
|
|
Any methods to get the coordinates (upper left, bottom right) of the AppBar? I want to use it to resize other windows.
Thanks all!
|
|
|
|
|
If you mean the Taskbar, then call SHAppBarMessage() with the message ABM_GETTASKBARPOS.
It sounds like you want to know the area of the desktop not covered by the Taskbar and other app bars. If that's so, then just call SystemParametersInfo(SPI_GETWORKAREA).
|
|
|
|
|
Hi there,
I tried this site to access the mail object form
the outlook from my
VC ++ using the script control.
But it is giving some error.
The code is ***
#import "C:\Program Files\Microsoft Script Control
\msscript.ocx"
using namespace MSScriptControl;
IScriptControlPtr
spScriptCtl(__uuidof(ScriptControl));
spScriptCtl->put_Language(bstrLanguage);
spScriptCtl->AddCode("Sub Test1\nSet myOlApp ="
"CreateObject\"Outlook.Application\"\n"
"MsgBox \"Hello World\"\n"
"Set nsMAPI = myOlApp.GetNameSpace\"MAPI\"\n"
"Set objInbox = nsMAPI.GetDefaultFolder\"6\"\n"
"i = 1\n"
"While i <= objInbox.Items.Count\n"
"Set objMail = objInbox.Items\" i \"\n"
"If objMail = \"Gimme ur contac........\" Then\n"
"MsgBox \"Hello World Before\"\n"
"End If\n"
"i = i + 1\n"
"Wend \nEnd Sub");
spScriptCtl->ExecuteStatement("Test1");
Sub MSOff()
'DESCRIPTION: A description was not provided.
'TODO: Put macro code here
'Create the Session Object
Set myOlApp = CreateObject("Outlook.Application")
Set nsMAPI = myOlApp.GetNameSpace("MAPI")
Set objInbox = nsMAPI.GetDefaultFolder(6)
i = 1
While i <= objInbox.Items.Count
Set objMail = objInbox.Items(i)
' check the name of the letter
If objMail = "RE: CST13598207ID - help" Then
' do stuff with objMail (like access contents) -
' see Outlook documentation for things you can
do...
End If
i = i + 1
Wend
End Sub
It is not showing error while icomiling.But it is
not even executing the "Test" method.The reason
why i telling is it is nit showing the Message Box
"Hello World Before". So what may be the reason
for not executing the Test method script.
Another problem is in the line
nsMAPI.GetDefaultFolder(6) .But in the macro i
write it as nsMAPI.GetDefaultFolder\"6\"\n". ANd
how can i write nsMAPI.GetDefaultFolder(6) there.I
want to get the message body if the message
matches the same.
Please help me out
Expecting your reply
Reny
|
|
|
|
|
Hi,
I have to upgrade a tool developed by VC++ ver1.52 (16 bit) to VC++ ver6.0 (32bit).
1. Is there any special care that needs to be taken ?
2. Is there a tool to help me in doing this.
thank you in advance
|
|
|
|
|
Is this an MFC program or a Windows SDK program?
For help with SDK programs, there is a program called PortTool.exe. It will walk through a source code file and tell you of things that need to be changed. I don't know where this tool comes from. Check MSDN to find it.
In my experience, vanilla MFC apps port fairly easily, though there are some minor changes to your source code (some commenting of code will get you there).
For SDK apps, there is a lot more work involved. One place that needs to change is that the WndProc parameters (WPARAM and LPARAM) change meaning. This means that you have to change your switch statements. This is also documented on MSDN.
|
|
|
|
|
Hi,
how can i use 256 color icons in CTreeCtrl?
Thank you for any helps in advance!
Mustafa Demirhan
|
|
|
|
|
How can I minimazi ONLY to System Tray?
Or have a icon on System Tray?
|
|
|
|
|
Here is an example about adding icon to the system tary:
<br />
#define WM_MY_NOTIFYICON WM_USER+100<br />
<br />
BOOL CMainFrame::TrayMessage(DWORD dwMessage, UINT uID, HICON hIcon, PSTR pszTip)<br />
{<br />
BOOL res;<br />
<br />
NOTIFYICONDATA tnd;<br />
<br />
tnd.cbSize = sizeof(NOTIFYICONDATA);<br />
tnd.hWnd = m_hWnd;<br />
tnd.uID = uID;<br />
<br />
tnd.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP;<br />
tnd.uCallbackMessage = WM_MY_NOTIFYICON;<br />
tnd.hIcon = hIcon;<br />
if (pszTip)<br />
{<br />
lstrcpyn(tnd.szTip, pszTip, sizeof(tnd.szTip));<br />
}<br />
else<br />
{<br />
tnd.szTip[0] = '\0';<br />
}<br />
<br />
res = Shell_NotifyIcon(dwMessage, &tnd);<br />
<br />
if (hIcon)<br />
DestroyIcon(hIcon);<br />
<br />
return res;<br />
}<br />
<br />
void CMainFrame::NotifyDelete()<br />
{<br />
HICON hIcon;<br />
CWinApp *theApp=::AfxGetApp();<br />
hIcon=theApp->LoadIcon(IDR_MAINFRAME);<br />
TrayMessage(NIM_DELETE, IDR_MAINFRAME, hIcon, "WinScheduler");<br />
}<br />
<br />
void CMainFrame::NotifyAdd()<br />
{<br />
HICON hIcon;<br />
CWinApp *theApp=::AfxGetApp();<br />
hIcon=theApp->LoadIcon(IDR_MAINFRAME);<br />
TrayMessage(NIM_ADD, IDR_MAINFRAME, hIcon, "WinScheduler");<br />
}<br />
<br />
long CMainFrame::OnTrayIconNotify(WPARAM wParam, LPARAM lParam)<br />
{<br />
switch (lParam)<br />
{<br />
case WM_LBUTTONDOWN:<br />
{<br />
CWinApp *theApp=::AfxGetApp();<br />
CWnd *mainWnd=theApp->m_pMainWnd;<br />
if(mainWnd->IsIconic())<br />
{<br />
mainWnd->ShowWindow(SW_RESTORE);<br />
}<br />
mainWnd->SetForegroundWindow();<br />
}<br />
break;<br />
case WM_RBUTTONDOWN:<br />
break;<br />
}<br />
return 0;<br />
}<br />
Then add
ON_MESSAGE(WM_MY_NOTIFYICON, OnTrayIconNotify)
between
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) and
END_MESSAGE_MAP()
This adds an icon to the system tray and when you click on it it activates the window.
There is an article about removing your program's from taskbar in this site.
Best Regards.
Mustafa Demirhan
|
|
|
|
|
Sorry, I forgot the followings:
you have to add the following code to OnCreateClient (or add to another initialization code)
<br />
NotifyAdd();<br />
Then you have to call NotifyDelete(); in OnClose method.
Mustafa Demirhan
|
|
|
|
|
Just use WS_EX_TOOLWINDOW to eliminate the window from the taskbar.
See: http://msdn.microsoft.com/library/psdk/shellcc/shell/shell_int/taskbar.htm
|
|
|
|
|
(1) How can I play waw files with MFC?
(2) How can I play waw files with API?
|
|
|
|