Simple QQ communication function (3)

Source: Internet
Author: User

Part 3: login interface design and code

I. Interface Design

1 .:

2. Interface Design:

(1) like QQ's login interface, three labels are put in the upper right corner for closing, minimizing, and setting, and their click events are used as buttons.

(2) Put an image in a picturebox.

(3) Use tablelayoutpanel layout.

(4) Put the online pictures on the left side of tablelayoutpanel and in the lower right corner of the picture in a panel, which occupies three rows.

(5) The user name uses ComboBox, the password box uses Textbox, and a button is used for login.

(6) name of each control used:

Close button: closewindow, minimize button: smallwindow, big image above: picturebox1, status icon: zhuangtai;

Username box: combuid, password box: textpwd, login button: btnlogin, put the left and right pictures imagelist1;

Right-click contextmenustrip1 and right-click imagelist2.

Ii. Code Design:

// Record the change status. The default value is 1, which is online int zt = 1. // record the private string uid variable of the consumer; Public String uid {get {return uid ;} set {uid = value ;}} public login () {initializecomponent () ;}// the private void login_load (Object sender, eventargs E) is loaded on the Interface {// The setting is transparent, you must first set the backcolor of the transparent control to transparent shezhi in the design. parent = This. picturebox1; smallwindow. parent = This. picturebox1; closewindow. parent = This. picturebox1; zhuangtai. parent = This. picturebox2; // set picturebox3.image = imagelist1.images [0]; picturebox4.image = imagelist1.images [1];} // close the window button private void closewindow_click (Object sender, eventargs) {This. close () ;}// hover the mouse button to change the color. Private void closewindow_mouseenter_1 (Object sender, eventargs e) {closewindow. backcolor = color. lightcoral;} // close the button and move the cursor away from the restoration color private void closewindow_mouseleave_1 (Object sender, eventargs e) {closewindow. backcolor = color. transparent;} // minimize the private void smallwindow_click_1 (Object sender, eventargs e) {This. windowstate = formwindowstate. minimized;} // The Code int X; int y; private void picturebox#mousedown (Object sender, mouseeventargs e) {x = E. x; y = E. y;} private void picturebox#mousemove (Object sender, mouseeventargs e) {If (E. button = system. windows. forms. mousebuttons. left) {This. left = This. left + (E. x-x); this. top = This. top + (E. y-y) ;}// change to the password box when the Password box gets the focus, clear, and change the font color private void textpwd_enter (Object sender, eventargs e) {textpwd. TEXT = ""; textpwd. forecolor = color. black; textpwd. passwordchar = convert. tochar ("● ");}
// When the User Name box is clicked in, it is cleared. The font color changes. Private void combuid_mousedown_1 (Object sender, mouseeventargs e) {combuid. TEXT = ""; combuid. forecolor = color. black ;}
// When the login button is pressed, private void btnlogin_click_1 (Object sender, eventargs e) {// retrieve the username and password and query the database string uid = combuid. text. tostring (); string Pwd = textpwd. text. tostring (); userstableadapter ADP = new userstableadapter (); qqdata. usersdatatable table = ADP. logincheck (UID, PWD); // determine whether the logon is successful if (table. rows. count> 0) {// This. set dialogresult to OK this. dialogresult = dialogresult. OK; uid = table [0]. username; // pass the user name To uid ADP. updatestatebycode (ZT, UID); // change the state to ADP. updatelasttimebycode (datetime. now, UID); // record the logon time} else {MessageBox. show ("Account Password error! ");}}

// Right-click the icon in the lower-right corner of the profile picture.

Private void zhuangtai_click_1 (Object sender, eventargs E)
{
Contextmenustrip1.show (zhuangtai, 0, 18 );
}

// Right-click the menu to select online

Private void online toolstripmenuitem_click (Object sender, eventargs E)
{
Zhuangtai. Image = imagelist2.images [3];
Zt = convert. toint32 (online toolstripmenuitem. Tag );
}

// When the context menu is invisible

Private void stealth toolstripmenuitem_click (Object sender, eventargs E)
{
Zhuangtai. Image = imagelist2.images [2];
Zt = convert. toint32 (stealth toolstripmenuitem. Tag );
}

// Right-click the menu to select a busy time

Private void busy toolstripmenuitem_click (Object sender, eventargs E)
{
Zhuangtai. Image = imagelist2.images [1];
Zt = convert. toint32 (busy toolstripmenuitem. Tag );
}

// Right-click the menu and choose exit

Private void exit toolstripmenuitem_click (Object sender, eventargs E)
{
Zhuangtai. Image = imagelist2.images [0];
Zt = convert. toint32 (exit toolstripmenuitem. Tag );
}

 

Simple QQ communication function (3)

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.