是一个对话框程序.我从另外一个程序中启动它,但不想看到第2个任务栏图标.#include <windows.h>
#include "resource.h"char buffer[255];BOOL CALLBACK PromptDlgProc(HWND,UINT,WPARAM,LPARAM);int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstnce, LPSTR lpCmdLine, int nShowCmd)
{
strcpy(buffer,lpCmdLine);
DialogBox(hInstance,MAKEINTRESOURCE(IDD_PROMPT),NULL,PromptDlgProc);
return 0;
}BOOL CALLBACK PromptDlgProc (HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
HDC hdc;
HFONT holdfont,hnewfont;
PAINTSTRUCT ps;
RECT rect_client,rect_window;
int cxScreen,cyScreen;
switch (message)
{
case WM_INITDIALOG :
cxScreen = GetSystemMetrics (SM_CXSCREEN) ;
cyScreen = GetSystemMetrics (SM_CYSCREEN) ;
GetWindowRect(hDlg,&rect_window);
MoveWindow(hDlg,(cxScreen-(rect_window.right-rect_window.left))/2,
(cyScreen-(rect_window.bottom-rect_window.top))/2,
rect_window.right-rect_window.left,
rect_window.bottom-rect_window.top,
TRUE);
return TRUE ;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDOK :
case IDCANCEL :
EndDialog (hDlg, 0) ;
return TRUE ;
}
break ;
case WM_PAINT :
hdc=BeginPaint(hDlg, &ps);
GetClientRect(hDlg,&rect_client);
SetBkMode(hdc,TRANSPARENT);
hnewfont=CreateFont(
10, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
"MS Sans serif"); // lpszFacename
holdfont=SelectObject(hdc,hnewfont);
DrawText(hdc,buffer,-1,&rect_client,
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
EndPaint(hDlg,&ps);
SelectObject(hdc,holdfont);
DeleteObject(hnewfont);
return 0;
}
return FALSE ;
}
#include "resource.h"char buffer[255];BOOL CALLBACK PromptDlgProc(HWND,UINT,WPARAM,LPARAM);int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstnce, LPSTR lpCmdLine, int nShowCmd)
{
strcpy(buffer,lpCmdLine);
DialogBox(hInstance,MAKEINTRESOURCE(IDD_PROMPT),NULL,PromptDlgProc);
return 0;
}BOOL CALLBACK PromptDlgProc (HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
HDC hdc;
HFONT holdfont,hnewfont;
PAINTSTRUCT ps;
RECT rect_client,rect_window;
int cxScreen,cyScreen;
switch (message)
{
case WM_INITDIALOG :
cxScreen = GetSystemMetrics (SM_CXSCREEN) ;
cyScreen = GetSystemMetrics (SM_CYSCREEN) ;
GetWindowRect(hDlg,&rect_window);
MoveWindow(hDlg,(cxScreen-(rect_window.right-rect_window.left))/2,
(cyScreen-(rect_window.bottom-rect_window.top))/2,
rect_window.right-rect_window.left,
rect_window.bottom-rect_window.top,
TRUE);
return TRUE ;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDOK :
case IDCANCEL :
EndDialog (hDlg, 0) ;
return TRUE ;
}
break ;
case WM_PAINT :
hdc=BeginPaint(hDlg, &ps);
GetClientRect(hDlg,&rect_client);
SetBkMode(hdc,TRANSPARENT);
hnewfont=CreateFont(
10, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
"MS Sans serif"); // lpszFacename
holdfont=SelectObject(hdc,hnewfont);
DrawText(hdc,buffer,-1,&rect_client,
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
EndPaint(hDlg,&ps);
SelectObject(hdc,holdfont);
DeleteObject(hnewfont);
return 0;
}
return FALSE ;
}
ShowWindow(SW_HIDE);
这样的话是不是连窗口都没有了?
先添上
::SetWindowLong(hDlg,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
各位帮我回一下以下这贴,每人回复我想结贴都不行,影响我信誉分啊
http://community.csdn.net/Expert/topic/4182/4182062.xml?temp=.0710718