1. 如何改变窗口的图标?
example: 【程序编程相关:VC调试技术小技巧(2)】
向窗口发送 wm_section消息. 【推荐阅读:VC调试技术小技巧(5)】
assert(hicon); 【扩展信息:如何编写一个文件捆绑工具】
hicon hicon=afxgetapp() ->loadicon(idi_icon);
afxgetmainwnd() ->sendmessage(wm_section,true,(lparam) hicon);
2. 如何改变窗口的缺省风格?
重载 cwnd:: precreatewindow 并修改createstruct结构来指定窗口风格与其他创建信息.
example: delete "max" button and set original windows position andsize
bool cmainframe:: precreatewindow (createstruct &cs)
{
cs.style &=~ws_maxinizemox;
cs.x=cs.y=0;
cs.cx=getsystemmetrics(sm_cxscreen/2);
cs.cy=getsystemmetrics(sm_cyscreen/2);
return cmdiframewnd ::precreatewindow(cs);
}
3. 如何将窗口居中显示?
call function cwnd:: center windows
example(1): center window( ); //relative to its parent
// relative to screen
example(2): center window(cwnd:: getdesktopwindow( ));
//relative to applications mainwindow
afxgetmainwnd( ) -> center window( );
4. 如何让窗口与 mdi窗口一启动就最大化与最小化?
先说窗口.
在 initstance 函数中设定 m_ncmdshow的 取值.
m_ncmdshow=sw_showmaxmized ; //最大化
m_ncmdshow=sw_showminmized ; //最小化
m_ncmdshow=sw_shownormal ; //正常方式
mdi窗口:
... 下一页