100 VC small project development: 1. Imitation QQ Main Interface

Source: Internet
Author: User

100 VC small project development: 1. Imitation QQ Main Interface

Author July

------------------

1. I am here to fulfill my promise. As mentioned in a previous blog post,

After finishing the Microsoft and other interview series v0.1, the source code of the 100 sets of VC projects will be released. Now is the time.

2. If you have any questions, I hope you will not correct them. : D.

--------------------------

 

I think many people have done this QQ-like interface before. Therefore, this article will be as short as possible.

Let's take a look at the last one (Hai Han is also recommended for the rough interface ):

====

Oh, that's right. My QQ avatar is Shouti. My brother and I both like this tennis prince.

Because there is no skin library for qq2010, qq2008's skin is stolen. : D.

-------------------------------------------------------------------------------

 

1. Create a dialog box in the myicqapp file:

Cmyicqdlg DLG;
M_pmainwnd = & DLG;
Int nresponse = DLG. domodal ();
If (nresponse = idok)
{
// Todo: Place code here to handle when the dialog is
// Dismissed with OK
}
Else if (nresponse = idcancel)
{
// Todo: Place code here to handle when the dialog is
// Dismissed with cancel
}

// Since the dialog has been closed, return false so that we exit
// Application, rather than start the application's message pump.
Return false;

 

Ii. initialization of the Main Dialog box on the interface:

Bool cmyicqdlg: oninitdialog ()
{
Cdialog: oninitdialog ();

// Set the icon for this dialog. The framework does this automatically
// When the application's main window is not a dialog
Seticon (m_hicon, true); // set big icon
Seticon (m_hicon, false); // set small icon
 
// Todo: add extra initialization here

// 1. Draw the main interface, close, zoom in or zoom out, QQ profile picture, menu button, display status, mail, and other buttons.

// Keyword:Setbmp
Crect RC; getclientrect (& rc );

// Close BTN
Btnclose. Create (null, ws_visible | ws_child, crect (RC. Right-35, 0, RC. Right-5, 19), this, de_wm_close );
Btnclose. setbmp (idb_bit_close_normal, idb_bit_close_hover, idb_bit_close_hdown, null );
// CRO BTN
Btncro. Create (null, ws_visible | ws_child, crect (RC. Right-66, 0, RC. Right-36, 19), this, de_wm_cro );
Btncro. setbmp (idb_bit_cro_normal, idb_bit_cro_hover, idb_bit_cro_hdown, null );
// Min BTN
Btnmin. Create (null, ws_visible | ws_child, crect (RC. Right-97, 0, RC. Right-67, 19), this, de_wm_min );

Btnmin. setbmp (idb_bit_min_normal, idb_bit_min_hover, idb_bit_min_hdown, null );

// Head BTN
Btnhead. Create (null, ws_visible | ws_child, crect (,), this, de_wm_head );
Btnhead. setbmp (idb_bit_head, null );

// Menu BTN
Btnmenu. Create (null, ws_visible | ws_child, crect (0, RC. Bottom-34, 54, RC. Bottom), this, de_wm_menu );
Btnmenu. setbmp (idb_bit_menu_normal, idb_bit_menu_hover, idb_bit_menu_hdown, null );

Btnstate. Create ("stealth", ws_visible | ws_child, crect (, 115,70), this, de_wm_state );
Btnstate. seticon (idi_state, 16 );

Btnmail. Create ("(0)", ws_visible | ws_child, crect (,), this, de_wm_mail );
Btnmail. seticon (idi_mail, 16 );
 
 
// 2. Draw the button at the bottom, mobile phone, QQ music, pet, and QQ space

// Keyword:Seticon
Btnmobile. Create (null, ws_visible | ws_child, crect (30, RC. Bottom-55, 50, RC. Bottom-35), this, de_wm_mobile );
Btnmobile. seticon (idi_mobile, 16 );

Btnmusic. Create (null, ws_visible | ws_child, crect (55, RC. Bottom-55, 75, RC. Bottom-35), this, de_wm_music );
Btnmusic. seticon (idi_music, 16 );

Btnpet. Create (null, ws_visible | ws_child, crect (80, RC. Bottom-55, 100, RC. Bottom-35), this, de_wm_pet );
Btnpet. seticon (idi_pet, 16 );

Btnresearch. Create (null, ws_visible | ws_child, crect (105, RC. Bottom-55, 125, RC. Bottom-35), this, de_wm_research );
Btnresearch. seticon (idi_research, 16 );

Btnzone. Create (null, ws_visible | ws_child, crect (130, RC. Bottom-55, 150, RC. Bottom-35), this, de_wm_zone );
Btnzone. seticon (idi_zone, 16 );

Crect rcfolderctrl; rcfolderctrl. setrect (RC. Left + 35, RC. Top + 89, RC. Right-4, RC. Bottom-68 );

 

// 3. draw contact groups, my friends, my classmates and others
cgfxoutbarctrl * GFX = new cgfxoutbarctrl;
DWORD DwF = cgfxoutbarctrl: fdragitems | cgfxoutbarctrl :: feditgroups | generation: fedititems | generation: fremovegroups |
cgfxoutbarctrl: fremoveitems | generation: faddgroups | generation: fanimation
| generation: fselhighlight;
GFX-> Create (ws_visible | ws_child, rcfolderctrl, this, 111111, DwF);
GFX-> addfolder ("Friends of Life", 0 );
GFX-> addfolder ("today's students", 1);
GFX-> addfolder ("Siblings", 2 );
GFX-> addfolder ("", 3);
GFX-> addfolder ("Donghua Zhiyou", 4 );
GFX-> addfolder ("csdn group", 5);
GFX-> addfolder ("100 question discussion", 6 );
// GFX-> insertitem (, "Liu ruoying",);
// GFX-> insertitem (, "001 ", );
// GFX-> insertitem (, "002",);

Cinternet * Net = new cinternet;
Net-> Create (null, null, ws_child | ws_visible, rcfolderctrl, this, 22222222 );
Net-> showwindow (sw_hide );

// 4. Pat, online movie, and so on the left of the main screen.
/// Tab

// Keyword:Seticon
Tabmem. Create (null, ws_child | ws_visible, crect (35,300,), this, de_wm_mem );
// Tabmem. addtabitem (idb_bit_tab_normal, idb_bit_tab_hover, idb_bit_tab_hover, idi_pai, null );
Tabmem. setbmp (idb_bit_tab_normal, idb_bit_tab_hover, idb_bit_tab_hdown );
Tabmem. seticon (0, idi_pai, GFX );
Tabmem. seticon (1, idi_it, net );
Tabmem. seticon (2, idi_one, null );
Tabmem. seticon (3, idi_heart, null );
Tabmem. seticon (4, idi_online, null );
Tabmem. m_icurrentselect = 0;
// Tabmem. seticon (idi_pai, null );

// Crect rect; getclientrect (& rect );
// Cmaintabctrl * PTAB = new cmaintabctrl;
// PTAB-> Create (ws_visible | ws_child, rect, this, 10000 );

 
// Cfolderctrl * pfolder = new cfolderctrl;
// Pfolder-> Create (ws_visible | ws_child, rect, PTAB, 20000 );
// Cfolderctrl * pfolder = new cfolderctrl;
// Pfolder-> Create (ws_visible | ws_child, crect (,), this, de_wm_close );
Return true; // return true unless you set the focus to a control
}

 

3. Draw the top corner and center section.

// Keyword:Cbitmap

Void cmyicqdlg: onpaint ()
{
If (isiconic ())
{
Cpaintdc DC (this); // device context for painting

Sendmessage (wm_iconerasebkgnd, (wparam) DC. getsafehdc (), 0 );

// Center icon in client rectangle
Int cxicon = getsystemmetrics (sm_cxicon );
Int cyicon = getsystemmetrics (sm_cyicon );
Crect rect;
Getclientrect (& rect );
Int x = (rect. Width ()-cxicon + 1)/2;
Int y = (rect. Height ()-cyicon + 1)/2;

// Draw the icon
DC. drawicon (X, Y, m_hicon );
}
Else
{
Cpaintdc DC (this );
Crect RC; getclientrect (& rc );
// RC. inflaterect (csize (2, 12 ));
CDC memdc; memdc. createcompatibledc (& DC );
Cbitmap bit; bit. createcompatiblebitmap (& DC, RC. Width (), RC. Height ());
Cbitmap * oldbmp = memdc. SelectObject (& bit );
Memdc. drawedge (RC, edge_sunken, 0 );

// ------- Title1
// Title1 left
Cbitmap BMP title1left; BMP title1left. loadbitmap (idb_bit_title1_left );
Drawbmp bypoint (& memdc, BMP title1left, cpoint (0, 0 ));
// Title1 mid
Cbitmap BMP title1mid; BMP title1mid. loadbitmap (idb_bit_title1_mid );
Drawbmp bycrect (& memdc, BMP title1mid, crect (64,0, RC. Right-79, 22 ));
// Title1 right
Cbitmap BMP title1right; BMP title1right. loadbitmap (idb_bit_title1_right );
Drawbmp bypoint (& memdc, BMP title1right, cpoint (RC. Right-79, 0 ));

// ------- Title2
// Title2 left
Cbitmap BMP title2left; BMP title2left. loadbitmap (idb_bit_title2_left );
Drawbmp bypoint (& memdc, BMP title2left, cpoint (0, 22 ));
// Title2 mid
Cbitmap BMP title2mid; BMP title2mid. loadbitmap (idb_bit_title2_mid );
Drawbmp bycrect (& memdc, BMP title2mid, crect (63,22, RC. Right-115, 67 ));
// Title2 right
Cbitmap BMP title2right; BMP title2right. loadbitmap (idb_bit_title2_right );
Drawbmp bypoint (& memdc, BMP title2right, cpoint (RC. Right-115, 22 ));

// ------- Center
// Center left
Cbitmap bmpcenterleft; bmpcenterleft. loadbitmap (idb_bit_center_left );
Drawbmp bycrect (& memdc, bmpcenterleft, crect (0, 89, 35, RC. Bottom-68 ));
// Center right
Cbitmap bmpcenterright; bmpcenterright. loadbitmap (idb_bit_center_right );
Drawbmp bycrect (& memdc, bmpcenterright, crect (RC. Right-4, 89, RC. Right, RC. Bottom-68 ));

// ------- Bottom
// Bottom left
Cbitmap BMP bottomleft; BMP bottomleft. loadbitmap (idb_bit_botton_left );
Drawbmp bypoint (& memdc, BMP bottomleft, cpoint (0, RC. Bottom-68 ));
// Bottom mid
Cbitmap BMP bottommid; BMP bottommid. loadbitmap (idb_bit_bottom_mid );
Drawbmp bycrect (& memdc, BMP bottommid, crect (73, RC. Bottom-68, RC. Right-68, RC. Bottom ));
// Bottom right
Cbitmap BMP bottomright; BMP bottomright. loadbitmap (idb_bit_bottom_right );
Drawbmp bypoint (& memdc, BMP bottomright, cpoint (RC. Right-68, RC. Bottom-68 ));

// Bitblt
DC. bitblt (0, 0, RC. Width (), RC. Height (), & memdc, 0, 0, srccopy );
//
Cdialog: onpaint ();
}
}

// The system callthis to obtain the cursor to display while the user drags
// The minimized window.
Hcursor cmyicqdlg: onquerydragicon ()
{
Return (hcursor) m_hicon;
}

// Change client-MSG to caption-MSG
Uint cmyicqdlg: onnchittest (cpoint point)
{
// Todo: add your message handler code here and/or call default
 
Uint nhittest = cdialog: onnchittest (point );

If (nhittest = htclient)
Nhittest = htcaption;
Return nhittest;
}

// Set BMP by point
Void cmyicqdlg: drawbmp bypoint (CDC * PDC, cbitmap & mainbmp, const cpoint & pt)
{
CDC tmpdc; tmpdc. createcompatibledc (PDC );
Bitmap tmpbmp;
Mainbmp. getbitmap (& tmpbmp );
 
Cbitmap * oldbmp = tmpdc. SelectObject (& mainbmp );

PDC-> bitblt (Pt. X, Pt. Y, tmpbmp. bmwidth, tmpbmp. bmheight, & tmpdc, 0, srccopy );
 
Tmpdc. SelectObject (& oldbmp );
Oldbmp-> deleteobject ();
}

// Set BMP by crect
Void cmyicqdlg: drawbmp bycrect (CDC * PDC, cbitmap & bitrect, crect & rect)
{
CDC tmpdc; tmpdc. createcompatibledc (PDC );
Bitmap tmpbmp;
Bitrect. getbitmap (& tmpbmp );

Cbitmap * oldbmp = tmpdc. SelectObject (& bitrect );

For (INT y = rect. Top; y <rect. Bottom; y + = tmpbmp. bmheight)
{
For (INT x = rect. Left; x <rect. Right; x + = tmpbmp. bmwidth)
{
PDC-> bitblt (X, Y, tmpbmp. bmwidth, tmpbmp. bmheight, & tmpdc, 0, 0, srccopy );
}
}
Tmpdc. SelectObject (& oldbmp );
Oldbmp-> deleteobject ();
}

// Close
Void cmyicqdlg: ondeclose ()
{
Exit (0 );
}

// Minimize

Void cmyicqdlg: min ()
{
Showwindow (sw_minimize );
}

-------------------

. July and July December 22, 2010.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.