- 浏览: 597539 次
- 性别:
- 来自: 安徽
文章分类
最新评论
-
jianxin1009:
你说的答案是对的
Re: 一道微软的面试题(年薪40万) -
thrillerzw:
应该相信爱情
忽然相信爱情。。。 -
weng:
jaxchow 写道mikeandmore 写道我觉得国外之所 ...
国外项目的代码质量真是高啊 -
cinhoo:
怎么也应该叫大蛇蛋才对嘛
lazypy 这个小蛇蛋不错 -
rosolio:
这个怎么解决?
Hibernate Annotation的中@ManyToOne和CascadeType问题
一直崇拜c/c++的牛人,崇拜那些只有几百K甚至几十K的程序。
我知道只有C/C++可以帮助我。
我的内心发出狂热的呼喊:我要学C++
于是无奈之下安装了N个G的Visual studio。。。
Visual C++,我回来了,请不要抛弃我,虽然以前我没有耐心的学习你。。。
我潜心阅读MSDN的文档。。。
MFC,不是我想要的。。。一个很莫名奇妙的框架,以前就是他这个第三者破坏了我和C++良好的感情
Winform是什么??原来是披着C++外衣的.net狼。
我要的是最美最纯的C,接受C++其实是一种妥协,但还要我接受这些浮华的勒涩吗?NO!!!
我知道,windows下我也可以用printf来写最纯的C,但是,我们还需要GUI,除了要单纯的心,我们要一个美丽的脸庞。
GDI、GDIPlus,WIN API,非常好,我终于找到我的梦中情人了,我要的就是这样的最单纯的程序。
我潜心的读相关的文档,就像在读着盼望已久的情书。。。
TRUE,FALSE,VOID,怎么不是 true ,false ,void,我是不是看花了。
WCHAR NWPSTR, LPWSTR, PWSTR; 。。。 我理解这良苦用心,希望我更容易看懂。
INT_PTR,LRESULT 。。。
虽然我很爱她,但我终于忍不住对她发火了:美女,请问你真的是C小姐吗?你可以正常点说话吗?
Please help me , How could I found my Miss C ?
===================================
最后补充一下,看了下WCHAR,LPWSTR这些玩意的定义,最终是用到了 __wchar_t 这个非标准的关键字。
MS定义这些别名我想也是为了适应将来的编译器变化。
另外在32位和64位操作系统中,int、long、的长度也是不一样的,甚至64位windows和64位的 nix的long长度也不一样。
请看此文:一个长整数的自述
说到底 c/c++ 标准还不完善,但是我比较不满“Visual C++”的是,他太special了。
嘿,你用一个公用库来包装一切当然简单,无非是别人帮你处理了消息处理,你自己用C写写看吧,如果GTK可用,那QT和MFC不是一样么。
楼主是想用C+Win32 API来写,你明白不?
错 lz是除了MFC以外的C/C++写。
啊据说也要除去winform的。。
lz排除了mfc和winform,我来推荐gtk,但是没有人排挤Qt。嗯,就是这样。
嘿,你用一个公用库来包装一切当然简单,无非是别人帮你处理了消息处理,你自己用C写写看吧,如果GTK可用,那QT和MFC不是一样么。
楼主是想用C+Win32 API来写,你明白不?
非得在win下么,gtk这东西在linux下非常方便的,glade随便拖拖,生成一个gtkbuilder的xml,然后直接加载就好了。。。
你在耍小白么?诸如wchar是C++标准中的unicode字符,你就是滚到linux里也是如此.GCC gui的能力弱得要死.
另外有一些是windows api的,你不调用Windows API,何必关注?
LZ到底是要从C写GUI界面,还是用C++写GUI界面? 以我看来,你还是放弃想用C写界面的想法吧:一个什么都不做的Windows界面,用C大概要300多行,你自己要去处理所有的消息。。
用MFC创建个界面,那不是相当简单的么?何至于那么难哈?
涨见识了啊。gcc和gui能联系到一起。。。。真是搞笑。。。
再说wchar_t也不只是C++标准,见C99标准7.24节
你在耍小白么?诸如wchar是C++标准中的unicode字符,你就是滚到linux里也是如此.GCC gui的能力弱得要死.
另外有一些是windows api的,你不调用Windows API,何必关注?
LZ到底是要从C写GUI界面,还是用C++写GUI界面? 以我看来,你还是放弃想用C写界面的想法吧:一个什么都不做的Windows界面,用C大概要300多行,你自己要去处理所有的消息。。
用MFC创建个界面,那不是相当简单的么?何至于那么难哈?
下面就是纯C写的,不知道楼主看了有什么感想
我知道只有C/C++可以帮助我。
我的内心发出狂热的呼喊:我要学C++
于是无奈之下安装了N个G的Visual studio。。。
Visual C++,我回来了,请不要抛弃我,虽然以前我没有耐心的学习你。。。
我潜心阅读MSDN的文档。。。
MFC,不是我想要的。。。一个很莫名奇妙的框架,以前就是他这个第三者破坏了我和C++良好的感情
Winform是什么??原来是披着C++外衣的.net狼。
我要的是最美最纯的C,接受C++其实是一种妥协,但还要我接受这些浮华的勒涩吗?NO!!!
我知道,windows下我也可以用printf来写最纯的C,但是,我们还需要GUI,除了要单纯的心,我们要一个美丽的脸庞。
GDI、GDIPlus,WIN API,非常好,我终于找到我的梦中情人了,我要的就是这样的最单纯的程序。
我潜心的读相关的文档,就像在读着盼望已久的情书。。。
TRUE,FALSE,VOID,怎么不是 true ,false ,void,我是不是看花了。
WCHAR NWPSTR, LPWSTR, PWSTR; 。。。 我理解这良苦用心,希望我更容易看懂。
INT_PTR,LRESULT 。。。
虽然我很爱她,但我终于忍不住对她发火了:美女,请问你真的是C小姐吗?你可以正常点说话吗?
Please help me , How could I found my Miss C ?
===================================
最后补充一下,看了下WCHAR,LPWSTR这些玩意的定义,最终是用到了 __wchar_t 这个非标准的关键字。
MS定义这些别名我想也是为了适应将来的编译器变化。
另外在32位和64位操作系统中,int、long、的长度也是不一样的,甚至64位windows和64位的 nix的long长度也不一样。
请看此文:一个长整数的自述
说到底 c/c++ 标准还不完善,但是我比较不满“Visual C++”的是,他太special了。
评论
11 楼
xuby
2009-11-13
用 Qt 是王道。MFC设计理念太落后了,相当山寨。
10 楼
mikeandmore
2009-11-13
ray_linn 写道
mikeandmore 写道
于是给lz个sample。顺便来反驳一下C写UI是绝对恶心的观点。
一共25行
#include <gtk/gtk.h> static void btn_clicked(GtkButton<script type="text/javascript" src="http://www.iteye.com/javascripts/tinymce/themes/advanced/langs/zh.js"></script><script type="text/javascript" src="http://www.iteye.com/javascripts/tinymce/plugins/javaeye/langs/zh.js"></script>* wid, gpointer user_data) { GtkWidget* dlg = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Hello World!"); gtk_dialog_run(GTK_DIALOG(dlg)); gtk_widget_destroy(dlg); } int main(int argc, char* argv[]) { gtk_init(&argc, &argv); GtkWidget* win = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget* btn = gtk_button_new_with_label("click me"); g_signal_connect(btn, "clicked", G_CALLBACK(btn_clicked), NULL); gtk_container_add(GTK_CONTAINER(win), btn); gtk_widget_show_all(win); gtk_main(); return 0; }
一共25行
嘿,你用一个公用库来包装一切当然简单,无非是别人帮你处理了消息处理,你自己用C写写看吧,如果GTK可用,那QT和MFC不是一样么。
楼主是想用C+Win32 API来写,你明白不?
错 lz是除了MFC以外的C/C++写。
啊据说也要除去winform的。。
lz排除了mfc和winform,我来推荐gtk,但是没有人排挤Qt。嗯,就是这样。
9 楼
ray_linn
2009-11-13
mikeandmore 写道
于是给lz个sample。顺便来反驳一下C写UI是绝对恶心的观点。
一共25行
#include <gtk/gtk.h> static void btn_clicked(GtkButton* wid, gpointer user_data) { GtkWidget* dlg = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Hello World!"); gtk_dialog_run(GTK_DIALOG(dlg)); gtk_widget_destroy(dlg); } int main(int argc, char* argv[]) { gtk_init(&argc, &argv); GtkWidget* win = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget* btn = gtk_button_new_with_label("click me"); g_signal_connect(btn, "clicked", G_CALLBACK(btn_clicked), NULL); gtk_container_add(GTK_CONTAINER(win), btn); gtk_widget_show_all(win); gtk_main(); return 0; }
一共25行
嘿,你用一个公用库来包装一切当然简单,无非是别人帮你处理了消息处理,你自己用C写写看吧,如果GTK可用,那QT和MFC不是一样么。
楼主是想用C+Win32 API来写,你明白不?
8 楼
mikeandmore
2009-11-13
于是给lz个sample。顺便来反驳一下C写UI是绝对恶心的观点。
一共25行
#include <gtk/gtk.h> static void btn_clicked(GtkButton* wid, gpointer user_data) { GtkWidget* dlg = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Hello World!"); gtk_dialog_run(GTK_DIALOG(dlg)); gtk_widget_destroy(dlg); } int main(int argc, char* argv[]) { gtk_init(&argc, &argv); GtkWidget* win = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget* btn = gtk_button_new_with_label("click me"); g_signal_connect(btn, "clicked", G_CALLBACK(btn_clicked), NULL); gtk_container_add(GTK_CONTAINER(win), btn); gtk_widget_show_all(win); gtk_main(); return 0; }
一共25行
7 楼
mikeandmore
2009-11-13
七猫 写道
在win上要是不嫌界面不好看的话,可以试试gtk<script type="text/javascript" src="http://www.iteye.com/javascripts/tinymce/themes/advanced/langs/zh.js"></script><script type="text/javascript" src="http://www.iteye.com/javascripts/tinymce/plugins/javaeye/langs/zh.js"></script>这玩意儿,我觉得这东东写些简单的程序用glade生成xml还是比较方便的。
非得在win下么,gtk这东西在linux下非常方便的,glade随便拖拖,生成一个gtkbuilder的xml,然后直接加载就好了。。。
6 楼
mikeandmore
2009-11-13
ray_linn 写道
mikeandmore 写道
lz投奔linux吧。。。。
你在耍小白么?诸如wchar是C++标准中的unicode字符,你就是滚到linux里也是如此.GCC gui的能力弱得要死.
另外有一些是windows api的,你不调用Windows API,何必关注?
LZ到底是要从C写GUI界面,还是用C++写GUI界面? 以我看来,你还是放弃想用C写界面的想法吧:一个什么都不做的Windows界面,用C大概要300多行,你自己要去处理所有的消息。。
用MFC创建个界面,那不是相当简单的么?何至于那么难哈?
涨见识了啊。gcc和gui能联系到一起。。。。真是搞笑。。。
再说wchar_t也不只是C++标准,见C99标准7.24节
5 楼
七猫
2009-11-12
折腾加自虐。
4 楼
七猫
2009-11-12
在win上要是不嫌界面不好看的话,可以试试gtk这玩意儿,我觉得这东东写些简单的程序用glade生成xml还是比较方便的。
3 楼
ray_linn
2009-11-12
mikeandmore 写道
lz投奔linux吧。。。。
你在耍小白么?诸如wchar是C++标准中的unicode字符,你就是滚到linux里也是如此.GCC gui的能力弱得要死.
另外有一些是windows api的,你不调用Windows API,何必关注?
LZ到底是要从C写GUI界面,还是用C++写GUI界面? 以我看来,你还是放弃想用C写界面的想法吧:一个什么都不做的Windows界面,用C大概要300多行,你自己要去处理所有的消息。。
用MFC创建个界面,那不是相当简单的么?何至于那么难哈?
下面就是纯C写的,不知道楼主看了有什么感想
BOOL bOnTop, bGrayScale, bBackground = TRUE; COLORREF cForeground = RGB(255,255,255), cBackground = RGB(0,0,0); HBRUSH hBackGrnd; int iCopyMode = 0; /*/ ***** Function prototypes for static functions ***** /*/ void GrabColor (HWND hwnd, HWND hwndCtl); void UpdateDisplay (HWND hwnd, HWND hStatusRGB, HWND hStatusHex, int R, int G, int B); /*/ ***** Function prototypes for callback functions ***** /*/ BOOL CALLBACK DialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); /*/ ***** Function prototypes for message handlers ***** /*/ static void Dialog_OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify); HBRUSH Dialog_OnCtlColorStatic (HWND hwnd, HDC hdc, HWND hChild, int type); static void Dialog_OnHScroll (HWND hwnd, HWND hctl, UINT code, int pos); static BOOL Dialog_OnInitDialog (HWND hwnd, HWND hwndFocus, LPARAM lParam); void Dialog_OnTimer (HWND hwnd, UINT id); /*/ / / int WINAPI / / WinMain (HINSTANCE, HINSTANCE, LPSTR, int) / / / / PURPOSE: / / Entry point for the application. / / / / COMMENTS: / / This function initializes the application and processes the / / dialog box. /*/ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { /*/ / / Instead of using GetMessage(), TranslateMessage(), and DispatchMessage() / / for the main message loop, we simply create a Dialog Box and let Windows / / handle it internally. /*/ DialogBox (hInstance, MAKEINTRESOURCE(IDD_DIALOGBOX), NULL, (DLGPROC)DialogProc); /*/ clean up /*/ if(hBackGrnd) DeleteObject(hBackGrnd); return 1; /*/ These prevent 'unreferenced formal parameter' warnings /*/ hPrevInstance; lpCmdLine; nCmdShow; } /*/ / / BOOL CALLBACK / / DialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) / / / / PURPOSE: / / Dialog function for the Colorz dialog box. / / Processes messages sent by calling the / / appropriate functions /*/ BOOL CALLBACK DialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { /*/ The message cracker macros used here are defined in windowx.h /*/ switch (message) { case WM_COMMAND: /*/ Notification from a control /*/ return HANDLE_WM_COMMAND (hwnd, wParam, lParam, Dialog_OnCommand); case WM_CTLCOLORSTATIC: /*/ Paint a static control's color /*/ return HANDLE_WM_CTLCOLORSTATIC (hwnd, wParam, lParam, Dialog_OnCtlColorStatic); case WM_HSCROLL: /*/ Notification from a horizontal scrollbar /*/ return HANDLE_WM_HSCROLL (hwnd, wParam, lParam, Dialog_OnHScroll); case WM_INITDIALOG: /*/ Initialization of controls complete /*/ return HANDLE_WM_INITDIALOG (hwnd, wParam, lParam, Dialog_OnInitDialog); case WM_TIMER: /*/ Notification of timer interval /*/ return HANDLE_WM_TIMER (hwnd, wParam, lParam, Dialog_OnTimer); } return FALSE; } /*/ / / static void / / Dialog_OnCommand (HWND hwnd, int id, hwnd hwndCtl, UINT codeNotify) / / / / hwnd Window handle for the dialog box window / / id Specifies the identifier of the menu item, control, or accelerator. / / hwndCtl Handle of the control sending the message if the message / / is from a control, otherwise, this parameter is NULL. / / codeNotify Specifies the notification code if the message is from a control. / / This parameter is 1 when the message is from an accelerator. / / This parameter is 0 when the message is from a menu. / / / / PURPOSE: / / Handle the keyboard and control notifications. / / An OK button press, or Enter/Esc keypress / / all dismiss the Colorz dialog box. /*/ static void Dialog_OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) { /*/ The macros used here are defined in windowx.h /*/ switch (id) { case IDC_CHECK_GRAYSCL: if(Button_GetCheck(hwndCtl)==BST_CHECKED) bGrayScale = TRUE; else bGrayScale = FALSE; break; case IDC_CHECK_ONTOP: if(Button_GetCheck(hwndCtl)==BST_CHECKED) { bOnTop = TRUE; /*/ set the Colorz dialog on top of others /*/ SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); } else { bOnTop = FALSE; /*/ restore the Colorz dialog /*/ SetWindowPos(hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); } break; case IDC_CHECK_GRABCLR: GrabColor (hwnd, hwndCtl); break; case IDC_RADIO_BACKGND: bBackground = TRUE; /*/ update scroll bars to reflect selected color /*/ ScrollBar_SetPos(GetDlgItem(hwnd,IDC_SCROLLBAR_R),GetRValue(cBackground),TRUE); ScrollBar_SetPos(GetDlgItem(hwnd,IDC_SCROLLBAR_G),GetGValue(cBackground),TRUE); ScrollBar_SetPos(GetDlgItem(hwnd,IDC_SCROLLBAR_B),GetBValue(cBackground),TRUE); /*/ display output /*/ UpdateDisplay(hwnd, GetDlgItem(hwnd,IDC_STATIC_RGB),GetDlgItem(hwnd,IDC_STATIC_HEX), GetRValue(cBackground),GetGValue(cBackground),GetBValue(cBackground)); break; case IDC_RADIO_FOREGND: bBackground = FALSE; /*/ update scroll bars to reflect selected color /*/ ScrollBar_SetPos(GetDlgItem(hwnd,IDC_SCROLLBAR_R),GetRValue(cForeground),TRUE); ScrollBar_SetPos(GetDlgItem(hwnd,IDC_SCROLLBAR_G),GetGValue(cForeground),TRUE); ScrollBar_SetPos(GetDlgItem(hwnd,IDC_SCROLLBAR_B),GetBValue(cForeground),TRUE); /*/ display output /*/ UpdateDisplay(hwnd, GetDlgItem(hwnd,IDC_STATIC_RGB),GetDlgItem(hwnd,IDC_STATIC_HEX), GetRValue(cForeground),GetGValue(cForeground),GetBValue(cForeground)); break; case IDC_RADIO_OFF: iCopyMode = 0; /*/ force controls to repaint /*/ InvalidateRgn( GetDlgItem(hwnd,IDC_STATIC_RGB) ,NULL,TRUE); InvalidateRgn( GetDlgItem(hwnd,IDC_STATIC_HEX) ,NULL,TRUE); break; case IDC_RADIO_RGB: iCopyMode = 1; /*/ force controls to repaint /*/ InvalidateRgn( GetDlgItem(hwnd,IDC_STATIC_RGB) ,NULL,TRUE); InvalidateRgn( GetDlgItem(hwnd,IDC_STATIC_HEX) ,NULL,TRUE); break; case IDC_RADIO_HEX: iCopyMode = 2; /*/ force controls to repaint /*/ InvalidateRgn( GetDlgItem(hwnd,IDC_STATIC_RGB) ,NULL,TRUE); InvalidateRgn( GetDlgItem(hwnd,IDC_STATIC_HEX) ,NULL,TRUE); break; case IDCANCEL: if(hBackGrnd) DeleteObject(hBackGrnd); /*/ Clean Up /*/ EndDialog (hwnd, TRUE); /*/ Dismiss the Colorz dialog box /*/ break; } /*/ This prevents 'unreferenced formal parameter' warnings /*/ codeNotify; } /*/ / / HBRUSH / / Dialog_OnCtlColorStatic (HWND hwnd, HDC hdc, HWND hChild, int type) / / / / hwnd Window handle for the dialog box window / / hdc Handle to device context for static control / / hChild Window handle for the static control / / type HOWDY / / / / PURPOSE: / / Determines the colors of a static control. /*/ HBRUSH Dialog_OnCtlColorStatic (HWND hwnd, HDC hdc, HWND hChild, int type) { /*/ This prevents 'unreferenced formal parameter' warnings /*/ type; /*/ The macros used here are defined in windowx.h /*/ if (hChild==GetDlgItem(hwnd,IDC_STATIC_PREVIEW)) { if(hBackGrnd) DeleteObject(hBackGrnd); hBackGrnd = CreateSolidBrush(cBackground); SetBkMode(hdc,TRANSPARENT); SetTextColor(hdc,cForeground); return hBackGrnd; } if (hChild==GetDlgItem(hwnd,IDC_STATIC_RGB)) { if(hBackGrnd) DeleteObject(hBackGrnd); hBackGrnd = CreateSolidBrush( GetSysColor(COLOR_3DFACE) ); SetBkMode(hdc,TRANSPARENT); if(iCopyMode==1) SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHT) ); else SetTextColor(hdc, GetSysColor(COLOR_BTNTEXT) ); return hBackGrnd; } if (hChild==GetDlgItem(hwnd,IDC_STATIC_HEX)) { if(hBackGrnd) DeleteObject(hBackGrnd); hBackGrnd = CreateSolidBrush( GetSysColor(COLOR_3DFACE) ); SetBkMode(hdc,TRANSPARENT); if(iCopyMode==2) SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHT) ); else SetTextColor(hdc, GetSysColor(COLOR_BTNTEXT) ); return hBackGrnd; } else return FORWARD_WM_CTLCOLORSTATIC(hwnd, hdc, hChild, DefWindowProc); } /*/ / / static void / / Dialog_OnHScroll (HWND hwnd, HWND hctl, UINT code, int pos) / / / / hwnd Window handle for the dialog box window / / hctl Handle of the control sending the message / / code Specifies the notification code if the message is from a control. / / pos Position user moved the scroll bar to / / / / PURPOSE: / / Handle the scroll bar notifications. / / and update the other controls as needed. /*/ static void Dialog_OnHScroll (HWND hwnd, HWND hctl, UINT code, int pos) { HWND hPreview; /*/ used to reference current control /*/ HWND hR,hG,hB; HWND hStatusRGB, hStatusHex; int posx; /*/ used to track current position /*/ int R,G,B; /*/ used to set global variables /*/ hR = GetDlgItem(hwnd,IDC_SCROLLBAR_R); hG = GetDlgItem(hwnd,IDC_SCROLLBAR_G); hB = GetDlgItem(hwnd,IDC_SCROLLBAR_B); switch(code) { /*/ The macros used here are defined in windowx.h /*/ /*/ / / This code handles common notifications from the scroll bars / / and if the user wants to keep his/her values in grayscale, it / / makes sure the bars are in uniform. (same value for all) /*/ case SB_THUMBPOSITION: /*/ user releases thumb /*/ if(bGrayScale) /*/ see if grayscale is checked /*/ { ScrollBar_SetPos(hR,pos,TRUE); ScrollBar_SetPos(hG,pos,TRUE); ScrollBar_SetPos(hB,pos,TRUE); } else ScrollBar_SetPos(hctl,pos,TRUE); break; case SB_THUMBTRACK: /*/ user drags thumb /*/ if(bGrayScale) /*/ see if grayscale is checked /*/ { ScrollBar_SetPos(hR,pos,TRUE); ScrollBar_SetPos(hG,pos,TRUE); ScrollBar_SetPos(hB,pos,TRUE); } else ScrollBar_SetPos(hctl,pos,TRUE); break; case SB_LINERIGHT: /*/ user clicks right arrow /*/ posx = ScrollBar_GetPos(hctl); posx += 1; if(bGrayScale) /*/ see if grayscale is checked /*/ { ScrollBar_SetPos(hR,posx,TRUE); ScrollBar_SetPos(hG,posx,TRUE); ScrollBar_SetPos(hB,posx,TRUE); } else ScrollBar_SetPos(hctl,posx,TRUE); break; case SB_LINELEFT: /*/ user clicks left arrow /*/ posx = ScrollBar_GetPos(hctl); posx -= 1; if(bGrayScale) /*/ see if grayscale is checked /*/ { ScrollBar_SetPos(hR,posx,TRUE); ScrollBar_SetPos(hG,posx,TRUE); ScrollBar_SetPos(hB,posx,TRUE); } else ScrollBar_SetPos(hctl,posx,TRUE); break; case SB_PAGERIGHT: /*/ user pages right /*/ posx = ScrollBar_GetPos(hctl); posx += 5; if(bGrayScale) /*/ see if grayscale is checked /*/ { ScrollBar_SetPos(hR,posx,TRUE); ScrollBar_SetPos(hG,posx,TRUE); ScrollBar_SetPos(hB,posx,TRUE); } else ScrollBar_SetPos(hctl,posx,TRUE); break; case SB_PAGELEFT: /*/ user pages left /*/ posx = ScrollBar_GetPos(hctl); posx -= 5; if(bGrayScale) /*/ see if grayscale is checked /*/ { ScrollBar_SetPos(hR,posx,TRUE); ScrollBar_SetPos(hG,posx,TRUE); ScrollBar_SetPos(hB,posx,TRUE); } else ScrollBar_SetPos(hctl,posx,TRUE); break; } /*/ set IDC_PREVIEW to match the new values /*/ R = ScrollBar_GetPos(hR); G = ScrollBar_GetPos(hG); B = ScrollBar_GetPos(hB); hPreview = GetDlgItem(hwnd,IDC_STATIC_PREVIEW); hStatusRGB = GetDlgItem(hwnd,IDC_STATIC_RGB); hStatusHex = GetDlgItem(hwnd,IDC_STATIC_HEX); /*/ update display and variables /*/ UpdateDisplay(hwnd, hStatusRGB, hStatusHex, R, G, B); /*/ force control to repaint itself /*/ InvalidateRgn(hPreview,NULL,TRUE); } /*/ / / static BOOL / / Dialog_OnInitDialog (HWND hwnd, HWND hwndFocus, LPARAM lParam) / / / / PURPOSE: / / Function to handle any initialization necessary before / / the newly created window is shown. /*/ static BOOL Dialog_OnInitDialog (HWND hwnd, HWND hwndFocus, LPARAM lParam) { HFONT hFont; HICON hIcon; SCROLLINFO si; HINSTANCE hInst; /*/ Center the main window in the work area. /*/ CenterWnd(hwnd,NULL); /*/ The macros used here are defined in windowx.h /*/ hInst = GetWindowInstance(hwnd); /*/ Get a handle to the System font /*/ hFont = CreateFont( 10,0,0,0,FW_NORMAL,0,0,0, ANSI_CHARSET,OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, FF_SWISS,"System"); /*/ set the preview pane's font /*/ SetWindowFont(GetDlgItem(hwnd,IDC_STATIC_PREVIEW),hFont,TRUE); /*/ we are done with the font /*/ DeleteObject(hFont); /*/ ***** INITIALIZATION ROUTINES ***** /*/ /*/ values for the R, G, and B scrollbars /*/ si.cbSize = sizeof(si); si.nMin = 0; /*/ Minimum value /*/ si.nMax = 255; /*/ Maximum value /*/ si.fMask = SIF_RANGE; /*/ Flag to indicate that want to manipulate ranges /*/ /*/ apply the data to the scroll bars /*/ SetScrollInfo(GetDlgItem(hwnd,IDC_SCROLLBAR_R),SB_CTL,&si,TRUE); SetScrollInfo(GetDlgItem(hwnd,IDC_SCROLLBAR_G),SB_CTL,&si,TRUE); SetScrollInfo(GetDlgItem(hwnd,IDC_SCROLLBAR_B),SB_CTL,&si,TRUE); /*/ / / The Button_SetCheck macro is defined in Windowsx.h. If you do not / / include the header, you'll have to use the SendMessage API directly. /*/ Button_SetCheck(GetDlgItem(hwnd, IDC_RADIO_BACKGND), BM_SETCHECK); Button_SetCheck(GetDlgItem(hwnd, IDC_RADIO_OFF), BM_SETCHECK); /*/ / / Use our custom icon for the dialog instead of the Windows' / / default icon on the title bar (and when using Alt+Tab) /*/ hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR); SendMessage(hwnd, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon); hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR); SendMessage(hwnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon); /*/ These prevent 'unreferenced formal parameter' warnings /*/ hwndFocus; lParam; return TRUE; } /*/ / / void / / Dialog_OnTimer (HWND hwnd, UINT id) / / / / hwnd Window handle for the dialog box window / / id Specifies the identifier of the timer / / / / PURPOSE: / / Receives timer notifications. /*/ void Dialog_OnTimer (HWND hwnd, UINT id) { /*/ The macros used here are defined in windowx.h /*/ static POINT spoint; POINT cursor; HDC hdc, hdcPrev; HWND hwndxy, hPreview; HWND hStatusRGB,hStatusHex; int R,G,B, AltKey; COLORREF rgb; /*/ is the user pressing either ALT key? /*/ AltKey = GetAsyncKeyState(VK_MENU); /*/ key isn't being pressed, so get out /*/ if(AltKey==0) return; /*/ ***** GRAB COLOR PROCESS ***** /*/ GetCursorPos(&cursor); if(cursor.x==spoint.x && cursor.y==spoint.y) return; spoint.x = cursor.x; spoint.y = cursor.y; /*/ get a handle to the window under the cursor /*/ hwndxy = WindowFromPoint(spoint); /*/ get a handle to the window for IDC_STATIC_PREVIEW /*/ hPreview = GetDlgItem(hwnd,IDC_STATIC_PREVIEW); /*/ get handles to both of the windows' DCs /*/ hdc = GetDC(hwndxy); hdcPrev = GetDC(hPreview); /*/ GetPixel requires client coordinates /*/ ScreenToClient(hwndxy,&cursor); rgb = GetPixel(hdc,cursor.x,cursor.y); /*/ / / The following is a workaround for the GetPixel API. If the / / cursor is over a titlebar or other non-client areas of the / / window it'll return -1 for the RGB intensities. In this case / / we use BitBlt to copy the color to our control and extract / / the the intensities from that. /*/ if(rgb==-1) /*/ check to see if intensities are valid /*/ { BitBlt(hdcPrev,0,0,1,1,hdc,cursor.x,cursor.y,SRCCOPY); rgb = GetPixel(hdcPrev,0,0); } /*/ we no longer need the handles, so we discard them /*/ ReleaseDC(hwndxy,hdc); ReleaseDC(hPreview,hdcPrev); /*/ retreive specific color intensities /*/ /*/ GetXValue macros are defined in windowx.h /*/ R = GetRValue(rgb); G = GetGValue(rgb); B = GetBValue(rgb); /*/ get a handle to the output static controls /*/ hStatusRGB = GetDlgItem(hwnd,IDC_STATIC_RGB); hStatusHex = GetDlgItem(hwnd,IDC_STATIC_HEX); /*/ display output /*/ UpdateDisplay(hwnd, hStatusRGB, hStatusHex, R, G, B); /*/ force control to repaint itself /*/ InvalidateRgn(hPreview,NULL,TRUE); /*/ This prevents 'unreferenced formal parameter' warnings /*/ id; } /*/ / / void / / GrabColor (HWND hwnd, HWND hwndCtl) / / / / hwnd Window handle for the dialog box window / / hwndCtl Window handle for the preview pane control / / / / PURPOSE: / / Initialize and prepares for the grab color / / process to begin /*/ void GrabColor (HWND hwnd, HWND hwndCtl) { /*/ The macros used here are defined in windowx.h /*/ BOOL bGrabColor; /*/ temp flag /*/ HWND hwndOnTop, hwndGrayScale; HWND hwndR,hwndG,hwndB; hwndOnTop = GetDlgItem (hwnd,IDC_CHECK_ONTOP); hwndGrayScale = GetDlgItem (hwnd, IDC_CHECK_GRAYSCL); hwndR = GetDlgItem (hwnd, IDC_SCROLLBAR_R); hwndG = GetDlgItem (hwnd, IDC_SCROLLBAR_G); hwndB = GetDlgItem (hwnd, IDC_SCROLLBAR_B); /*/ query state of the "Grab Color" checkbox and respond accordingly /*/ if(Button_GetCheck(hwndCtl)==BST_CHECKED) bGrabColor = TRUE; else bGrabColor = FALSE; /*/ / / The following will check and uncheck the appropriate controls / / and start and end the grab color process. /*/ if(bGrabColor) { /*/ initiate process /*/ Button_SetCheck(hwndOnTop,BST_CHECKED); Button_SetCheck(hwndGrayScale,BST_UNCHECKED); Button_Enable(hwndOnTop,FALSE); Button_Enable(hwndGrayScale,FALSE); SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); ScrollBar_Enable(hwndR,ESB_DISABLE_BOTH); ScrollBar_Enable(hwndG,ESB_DISABLE_BOTH); ScrollBar_Enable(hwndB,ESB_DISABLE_BOTH); /*/ / / The timer is set to trigger every 55 milliseconds. It is / / pointless to set it any faster for this application because / / due to hardeware timers' limitations you'll never get a / / message in under a 54.925 millsecond interval (without MM, / / ASM, or QueryPerformanceCounter workarounds). Accuracy is / / not imperative here, so we don't care. /*/ SetTimer(hwnd,ID_TIMER,55,NULL); } else { int R,G,B; /*/ terminate process /*/ Button_Enable(hwndOnTop,TRUE); Button_Enable(hwndGrayScale,TRUE); ScrollBar_Enable(hwndR,ESB_ENABLE_BOTH); ScrollBar_Enable(hwndG,ESB_ENABLE_BOTH); ScrollBar_Enable(hwndB,ESB_ENABLE_BOTH); KillTimer(hwnd,ID_TIMER); if(bOnTop) { Button_SetCheck(hwndOnTop,BST_CHECKED); SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); } else { Button_SetCheck(hwndOnTop,BST_UNCHECKED); SetWindowPos(hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); } if(bGrayScale) Button_SetCheck(hwndGrayScale,BST_CHECKED); else Button_SetCheck(hwndGrayScale,BST_UNCHECKED); /*/ do we need the current foreground or background color? /*/ if(bBackground) { /*/ GetXValue macros are defined in windowx.h /*/ R = GetRValue(cBackground); G = GetGValue(cBackground); B = GetBValue(cBackground); } else { /*/ GetXValue macros are defined in windowx.h /*/ R = GetRValue(cForeground); G = GetGValue(cForeground); B = GetBValue(cForeground); } /*/ update scroll bars to reflect selected color /*/ ScrollBar_SetPos(hwndR,R,TRUE); ScrollBar_SetPos(hwndG,G,TRUE); ScrollBar_SetPos(hwndB,B,TRUE); } } void UpdateDisplay (HWND hwnd, HWND hStatusRGB, HWND hStatusHex, int R, int G, int B) { char StatusRGB[20]; char StatusHex[20]; /*/ format the RGB output for display /*/ wsprintf(StatusRGB,"RGB: %d,%d,%d",R,G,B); /*/ format the Hexadecimal output for display /*/ if(R<16 && G<16 && B<16) wsprintf(StatusHex,"Hex: 0%X0%X0%X",R,G,B); else if(R<16 && G<16) wsprintf(StatusHex,"Hex: 0%X0%X%X",R,G,B); else if(R<16 && B<16) wsprintf(StatusHex,"Hex: 0%X%X0%X",R,G,B); else if(G<16 && B<16) wsprintf(StatusHex,"Hex: %X0%X0%X",R,G,B); else if(R<16) wsprintf(StatusHex,"Hex: 0%X%X%X",R,G,B); else if(G<16) wsprintf(StatusHex,"Hex: %X0%X%X",R,G,B); else if(B<16) wsprintf(StatusHex,"Hex: %X%X0%X",R,G,B); else wsprintf(StatusHex,"Hex: %X%X%X",R,G,B); /*/ update labels with new data /*/ SetWindowText(hStatusRGB,StatusRGB); SetWindowText(hStatusHex,StatusHex); /*/ post data to clipboard (if selected) /*/ if(iCopyMode == 1) /*/ Advance pointer by 5 to clip 'RGB: ' /*/ AddClipboardText(hwnd,StatusRGB+5); else if(iCopyMode == 2) /*/ Advance pointer by 5 to clip 'Hex: ' /*/ AddClipboardText(hwnd,StatusHex+5); if(bBackground) /*/ set the background color of the static control /*/ cBackground = RGB(R,G,B); else /*/ set the foreground color of the static control /*/ cForeground = RGB(R,G,B); }
2 楼
mikeandmore
2009-11-12
lz投奔linux吧。。。。
1 楼
jasongreen
2009-11-12
WTL... TAKE a try...
发表评论
-
需要学习的
2010-08-11 15:41 1462今日和felinx聊天,发现有很多东西要了解 greenle ... -
文盲没有工作的权利吗??
2010-05-18 10:40 1052许多公司入职需要学历、学位证明。有些公司不要求学历,但在入职时 ... -
此时,听到小孩哭声
2010-04-21 04:28 80为什么非要选分类。。。。 这个点,凌晨4:40,什么人,打小 ... -
编写高性能、轻量级的互联网应用是一种社会责任
2010-04-20 17:57 1234如果你的网站访问量很大,但是服务器端性能很差,那就会浪费浏览者 ... -
中国现存的有思想的人
2009-11-24 15:17 218菩提达摩东来,只要寻一个不受人惑的人。 李敖说我就是那个不受 ... -
招贤纳士
2009-10-09 12:56 180本公司现招聘 一、Python 开发人员 二、Flash 编程 ... -
Anti-autority
2009-08-19 08:46 873If we want to approache the Tao ... -
我关于家庭教育的一些想法
2009-07-21 17:52 1118耶稣说,如果你们能像孩子一样本真的话,那你就是一个伟大的人 ... -
黄日华的《银狐》
2009-06-19 12:29 1376老片子了。 昨晚看了几集。 经典啊。 里面只有白翎,宋仕元(吕 ... -
星际2要出现多少牛逼地图啊
2009-06-18 12:19 1282war3的地图编辑器我实在 ... -
21世纪最牛逼思想家的心路历程小结———哲学、宿命论
2009-06-16 01:30 2895本文出现了太多“我” ... -
看了一下午的《莲花争霸》
2009-06-15 02:03 1058这部《莲花争霸》真是经典中的经典啊 这部的化妆、武打设计,在当 ... -
和姐姐聊天了
2009-06-05 14:26 1121好久没和姐姐说太多的话。 最近开着QQ。 今天聊了很多。 ... -
忽然相信爱情。。。
2009-06-04 13:43 1235有那么一瞬间。。。 比如此时。。。 忽然相信爱情。。。 ... -
快乐仍需随心,寂寞依然随缘
2009-06-03 09:47 965“快乐随心,寂寞随缘” 这是大学时,我最喜欢的一句话。 心 ... -
北工大的和服女
2009-06-01 11:23 1651昨天发了个帖子,莫名移动到了水源,这里不就是水源吗?不理解。 ... -
CSDN上看到了强帖,无意间发现,我喜欢的是这样的“怪胎”
2009-05-31 18:32 1049强帖在此,一些男女宿 ... -
凡事太急,势必缘分早尽
2009-05-10 09:21 1052凡事太急,势必缘分早尽 关键就是一个度,做任何事,包括玩游戏 ... -
Heroes 综合能力TOP-TEN
2009-05-04 13:28 1014Heroes 综合能力TOP-TEN。 1) Sylar是h ... -
Dota地形浅析
2009-05-01 11:46 1506最近玩dota,尚处于菜鸟 ...
相关推荐
What is it ? ************ oRTP is a LGPL licensed C library implementing the RTP protocol (rfc3550)....There are instructions and Microsoft Visual C++ project files in build/win32native/oRTP.
My objective with this book is to teach you the essentials of C++ programming using both of the tech- nologies supported by Visual C++ 2008. The book provides a detailed tutorial on both flavors of ...
**4.8 Getting Started with Visual C++** - **Visual C++入门:** 使用Visual C++进行MapX开发的基础教程。 - **开发流程:** 描述从新建项目到运行项目的整个流程。 **4.9 Getting Started With Delphi** - **...
在本文中,我们将深入探讨如何使用Visual C++创建一个连连看小游戏,这是一款非常适合编程新手入门的项目。Visual C++是Microsoft开发的一款强大的集成开发环境(IDE),它提供了丰富的工具和库来支持C++编程,使得...
AppWizard has created this DMS application for you. This application not only demonstrates the...This file contains a summary of what you will find in each of the files that make up your DMS application.
### Visual C/C++ 的异常处理详解 #### 一、引言 在开发过程中,异常处理是一种重要的编程技术,用于管理程序执行过程中可能出现的各种错误或非预期情况。Visual C/C++ 提供了多种方式来处理异常,包括标准 C 语言...
// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_SHOWALLPROCESS_H__928B7E87_BDF8_4C4F_84D3_AF4D921C3CF8__INCLUDED_)
Scripts give you the possibility to change the behaviour of your C++ programs without any need to recompile your program. A real world example would be game programming: you only have to change the ...
《Visual C++中的异常处理深度解析》 Visual C++作为一款强大的开发工具,不仅支持标准的C++语言,还提供了对Microsoft Foundation Classes (MFC)的集成,这使得在异常处理方面,Visual C++有着独特的处理机制。...
**5.4 Creating MEX-files in Visual C++** 演示如何使用Visual C++创建MEX文件。 **5.5 Example** 提供一个具体的例子来展示MEX文件的创建过程。 **5.6 Further reading** 进一步阅读材料推荐。 **5.7 About ...
- **What are the specificities of the CeCILL license?** - The CeCILL license is a free software license compatible with the GNU GPL and designed specifically for French law. - **Who is behind CImg?**...
In this comprehensive guide on **C & C++ Win32 API Programming**, we delve into the essentials of developing Windows applications using the powerful Win32 API. The Win32 API is a set of programming ...
// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_MAILSERVER_H__CB181B60_A7D0_4663_B1F4_A97F7F2B9BAB__INCLUDED_)
SMLPack is a suite of multilingual support components package for Delphi & C++Builder. It can help you to make your application support multilingual user interface. It is a real AUTOMATIC tool for ...
- **Jeff Kent**:洛杉矶山谷学院计算机科学副教授,教授多种编程语言,包括Visual Basic、C++、Java等。他不仅是一位资深教师,还负责一家洛杉矶律师事务所的网络管理工作。 #### 学习资源特色 - **Hands-On ...
This file contains a summary of what you will find in each of the files that make up your maze application. maze.cpp This is the main application source file. maze.dsp This file (the project file)...
Now updated for the newest C++14 standard and the free Microsoft Visual C++ Community Edition, it will quickly make you productive with C++ even if you’ve never written a line of code! Brian ...