|
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?
|
|
|
|
|
You may try these API functions:
BOOL sndPlaySound(
LPCSTR lpszSound,
UINT fuSound
);
BOOL PlaySound(
LPCSTR pszSound,
HMODULE hmod,
DWORD fdwSound
);
The same for MFC applications
Cheers,
Paolo.
|
|
|
|
|
This is on NT 4.0, SP6 using dev studio 6.0, sp4
I've just upgraded to these to try to fix the problem I'm
about to describe. The code I'm describing used to work, then one day I noticed it no longer worked, and I hadn't touched the code! I think a service pack or something broke
the code. I've seen this once before and the only fix that
worked was to reinstall the OS and all the tools. I don't want to do that .
The code is some code that given an address uses the SymGetLineFromAddr() function in imagehlp.dll to get the
line number. I'm using the fix that John Robbins provided that accounts for the address not matching a line's exact
address. This used to work, but now I get no file or line
number information.
Anyone come across this and worked out how to fix it?
Cheers
Stephen (2 questions in 1 day...)
|
|
|
|
|
The problem is probably that the ImageHlp.dll was replaced by a service pack.
So the SymGetLineFromAddr() function is no longer present in your current NT4 version. (It's only available in the W2K aka NT5 version)
Since ImageHlp.dll is a redistributable you can replace it again with the most recent (W2K) version you can find.
Make sure your debug symbol files are A-OK.
If that does not help, re-read some of John Robbins' articles...
GBO.
|
|
|
|
|
Thanks,
But that isn't the problem. The functions are present and I am calling them, they just fail to return any valid info,
even thought the pdb files are valid.
I reinstalled the OS - which nicely trashed my partition table even though it shouldn't have, good job I had backups.
Stephen
|
|
|
|
|
Sorry my comments didn't help.
Can you use windbg on your system to read the Drwtsn32 "core" Dump files? This might give you a clue.
(you got to make DrWtsn32 your default debugger and let it generate core files but I am sure you already read how to do this in John Robbin's articles...)
You might want to change the debug info generation to "C7" compatible which is sufficient to read the line numbers and a get a function name context.
Then again if you reinstalled the OS, everything might be running OK now.
Good luck.
|
|
|
|
|
Has anyone had problems installing the latest platform SDK (August 2000 on CD 3)?
I can't get the installer to install. I've tried the advice in the readme, latest service packs everything. Fails
with error code 1603.
Thus I can't get the platform SDK to install.
This is on:-
Win NT 4.0, SP 6,
DevStudio 6, sp 4.
Stephen Kellett
snail@objmedia.demon.co.uk
|
|
|
|
|
I don't have an solid answer for you, but FYI:
Error code 1603 means:
The file [2][3] is being held in use{ by the following process: Name: [4], Id: [5], Window Title: '[6]'}.
|
|
|
|
|
When I use TransparentBlt , I get a 1st chance exception, althoght the image appears as I had hoped, eventually, the function fails and the image doesn't appear . Any Ideas, I'm pulling my hair out on this one.
Does it in Win2000 and 98
|
|
|
|
|
How do I set the resolution of a dialog to a specific setting, for example 640x480. Also, when this is done do all coinciding dialogs have this resolution or do they all have to be set to 640x480 in the same manner?
|
|
|
|