當前位置:首頁 » 操作系統 » 界面源碼

界面源碼

發布時間: 2022-01-11 09:45:03

Ⅰ Windows界面C語言源代碼

你試試吧,我不清楚能不能在BORLAND C里運行。
#include<windows.h>

LRESULT CALLBACK MainWndProc(HWND,UINT,WPARAM,LPARAM);

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
char szClassName[]="MainWClass";
WNDCLASSEX wndclass;
// 用描述主窗口的參數填充WNDCLASSEX結構
wndclass.cbSize=sizeof(wndclass); // 結構的大小
wndclass.style=CS_HREDRAW|CS_VREDRAW|CS_OWNDC; // 指定如果大小改變就重畫
wndclass.lpfnWndProc=MainWndProc; // 窗口函數指針
wndclass.cbClsExtra=0; // 沒有額外的類內存
wndclass.cbWndExtra=0; // 沒有往外的窗口內存
wndclass.hInstance=hInstance; // 實例句柄
wndclass.hIcon=::LoadIcon(NULL,IDI_APPLICATION); // 使用預定義圖標
wndclass.hCursor=::LoadCursor(NULL,IDC_ARROW); // 使用預定義的游標
wndclass.hbrBackground=(HBRUSH)::GetStockObject(WHITE_BRUSH); // 使用白色背景畫刷
wndclass.lpszMenuName=NULL; // 不指定菜單
wndclass.lpszClassName=szClassName; // 窗口類的名稱
wndclass.hIconSm=NULL; // 沒有類的小圖標
// 注冊這個窗口類
::RegisterClassEx(&wndclass);
// 創建主窗口
HWND hwnd=::CreateWindowEx(
0, // dwExStyle,擴展樣式
szClassName, // lpClassName,類名
"Window", // lpWindowName,標題
WS_OVERLAPPEDWINDOW, // dwStyle,窗口風格
CW_USEDEFAULT, // X,初始X坐標
CW_USEDEFAULT, // Y,初始Y坐標
CW_USEDEFAULT, // nWidth,寬度
CW_USEDEFAULT, // nHeight,高度
NULL, // hWndParent,父窗口句柄
NULL, // hMenu,菜單句柄
hInstance, // hInstance,程序實例句柄
NULL); // lpParam,用戶數據
if(hwnd==NULL)
{
::MessageBox(NULL,"創建窗口出錯!","出錯",MB_OK);
return -1;
}
// 顯示窗口,刷新窗口客戶區
::ShowWindow(hwnd,nCmdShow);
::UpdateWindow(hwnd);
// 從消息隊列中取出消息,交給窗口函數處理,直到GetMessage返回FALSE,結束消息循環
MSG msg;
while(::GetMessage(&msg,NULL,0,0))
{
// 轉換鍵盤消息
::TranslateMessage(&msg);
// 將消息發送到相應的窗口函數
::DispatchMessage(&msg);
}
// 當GetMessage返回FALSE時程序結束
return msg.wParam;
}

LRESULT CALLBACK MainWndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
char szText[]="最簡單的窗口程序!";
switch(message)
{
case WM_PAINT:
{
HDC hdc;
PAINTSTRUCT ps;
hdc=::BeginPaint(hwnd,&ps);
::EndPaint(hwnd,&ps);
return 0;
}
case WM_DESTROY:
::PostQuitMessage(0);
return 0;
}
return ::DefWindowProc(hwnd,message,wParam,lParam);
}

java 中 GUI登錄界面設計源代碼

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class Login {

private JFrame frame = new JFrame("登錄");
private Container c = frame.getContentPane();
private JTextField username = new JTextField();
private JPasswordField password = new JPasswordField();
private JButton ok = new JButton("確定");
private JButton cancel = new JButton("取消");
public Login(){
frame.setSize(300,200);
c.setLayout(new BorderLayout());
initFrame();
frame.setVisible(true);
}

private void initFrame() {

//頂部
JPanel titlePanel = new JPanel();
titlePanel.setLayout(new FlowLayout());
titlePanel.add(new JLabel("系統管理員登錄"));
c.add(titlePanel,"North");

//中部表單
JPanel fieldPanel = new JPanel();
fieldPanel.setLayout(null);
JLabel l1 = new JLabel("用戶名:");
l1.setBounds(50, 20, 50, 20);
JLabel l2 = new JLabel("密 碼:");
l2.setBounds(50, 60, 50, 20);
fieldPanel.add(l1);
fieldPanel.add(l2);
username.setBounds(110,20,120,20);
password.setBounds(110,60,120,20);
fieldPanel.add(username);
fieldPanel.add(password);
c.add(fieldPanel,"Center");

//底部按鈕
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout());
buttonPanel.add(ok);
buttonPanel.add(cancel);
c.add(buttonPanel,"South");
}

public static void main(String[] args){
new Login();
}

}

Ⅲ jsp登陸界面源代碼

1、login.jsp文件

<%@ page language="java" contentType="text/html; charset=GB18030"

pageEncoding="GB18030"%>

<%@ page import="java.util.*" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>登錄頁面</title>

</head>

<body>

<form name="loginForm" method="post" action="judgeUser.jsp">

<table>

<tr>

<td>用戶名:<input type="text" name="userName" id="userName"></td>

</tr>

<tr>

<td>密碼:<input type="password" name="password" id="password"></td>

</tr>

<tr>

<td><input type="submit" value="登錄" style="background-color:pink"> <input

type="reset" value="重置" style="background-color:red"></td>

</tr>

</table>

</form>

</body>

</html>

2、judge.jsp文件

<%@ page language="java" contentType="text/html; charset=GB18030"

pageEncoding="GB18030"%>

<%@ page import="java.util.*" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>身份驗證</title>

</head>

<body>

<%

request.setCharacterEncoding("GB18030");

String name = request.getParameter("userName");

String password = request.getParameter("password");

if(name.equals("abc")&& password.equals("123")) {

3、afterLogin.jsp文件

%>

<jsp:forward page="afterLogin.jsp">

<jsp:param name="userName" value="<%=name%>"/>

</jsp:forward>

<%

}

else {

%>

<jsp:forward page="login.jsp"/>

<%

}

%>

</body>

</html>

<%@ page language="java" contentType="text/html; charset=GB18030"

pageEncoding="GB18030"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>登錄成功</title>

</head>

<body>

<%

request.setCharacterEncoding("GB18030");

String name = request.getParameter("userName");

out.println("歡迎你:" + name);

%>

</body>

</html>

(3)界面源碼擴展閱讀:

java web登錄界面源代碼:

1、Data_uil.java文件

import java.sql.*;

public class Data_uil

{

public Connection getConnection()

{

try{

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

}catch(ClassNotFoundException e)

{

e.printStackTrace();

}

String user="***";

String password="***";

String url="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=***";

Connection con=null;

try{

con=DriverManager.getConnection(url,user,password);

}catch(SQLException e)

{

e.printStackTrace();

}

return con;

}

public String selectPassword(String username)

{

Connection connection=getConnection();

String sql="select *from login where username=?";

PreparedStatement preparedStatement=null;

ResultSet result=null;

String password=null;

try{

preparedStatement=connection.prepareStatement(sql);

preparedStatement.setString(1,username);

result=preparedStatement.executeQuery();//可執行的 查詢

if(result.next())

password=result.getString("password");

}catch(SQLException e){

e.printStackTrace();

}finally

{

close(preparedStatement);

close(result);

close(connection);

}

System.out.println("找到的資料庫密碼為:"+password);

return password;

}

public void close (Connection con)

{

try{

if(con!=null)

{

con.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

public void close (PreparedStatement preparedStatement)

{

try{

if(preparedStatement!=null)

{

preparedStatement.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

public void close(ResultSet resultSet)

{

try{

if(resultSet!=null)

{

resultSet.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

}

2、login_check.jsp:文件

<%@ page language="java" contentType="text/html; charset=utf-8"

pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>驗證用戶密碼</title>

</head>

<body>

<jsp:useBean id="util" class="util.Data_uil" scope="page" />

<%

String username=(String)request.getParameter("username");

String password=(String)request.getParameter("password");

if(username==null||"".equals(username))

{

out.print("<script language='javaScript'> alert('用戶名不能為空');</script>");

response.setHeader("refresh", "0;url=user_login.jsp");

}

else

{

System.out.println("輸入的用戶名:"+username);

String passwordInDataBase=util.selectPassword(username);

System.out.println("密碼:"+passwordInDataBase);

if(passwordInDataBase==null||"".equals(passwordInDataBase))

{

out.print("<script language='javaScript'> alert('用戶名不存在');</script>");

response.setHeader("refresh", "0;url=user_login.jsp");

}

else if(passwordInDataBase.equals(password))

{

out.print("<script language='javaScript'> alert('登錄成功');</script>");

response.setHeader("refresh", "0;url=loginSucces.jsp");

}

else

{

out.print("<script language='javaScript'> alert('密碼錯誤');</script>");

response.setHeader("refresh", "0;url=user_login.jsp");

}

}

%>

</body>

</html>

3、loginSucces.jsp文件

<%@ page language="java" contentType="text/html; charset=utf-8"

pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Insert title here</title>

</head>

<body>

<hr size="10" width="26%" align="left" color="green">

<font size="6" color="red" >登錄成功 </font>

<hr size="10" width="26%" align="left" color="green">

</body>

</html>

4、user_login.jsp文件

<%@ page language="java" contentType="text/html; charset=utf-8"

pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>登錄界面</title>

</head>

<body background="C:Userswin8workspaceLoginimage\_10.jpg" >

<center>

<br><br><br><br><br><br>

<h1 style="color:yellow">Login</h1>

<br>

<form name="loginForm" action="login_check.jsp" method="post">

<table Border="0" >

<tr >

<td>賬號</td>

<td><input type="text" name="username"></td>

</tr>

<tr>

<td>密碼</td>

<td><input type="password" name="password">

</td>

</tr>

</table>

<br>

<input type="submit" value="登錄" style="color:#BC8F8F">

</form>

</center>

</body>

</html>

熱點內容
平板電腦賬號登錄伺服器錯誤 發布:2024-12-23 11:41:07 瀏覽:98
金蝶kis專業版資料庫表 發布:2024-12-23 11:35:41 瀏覽:601
相冊已經加密如何改密碼 發布:2024-12-23 11:32:20 瀏覽:277
批量下載鏈接腳本 發布:2024-12-23 11:29:11 瀏覽:972
PHP畫a夢 發布:2024-12-23 11:28:01 瀏覽:199
嗯安一個密碼鎖多少錢 發布:2024-12-23 11:21:19 瀏覽:864
ftp主動被動模式工作流程圖 發布:2024-12-23 11:12:58 瀏覽:9
讓圖片說話有什麼安卓軟體 發布:2024-12-23 11:07:04 瀏覽:268
qq空間上傳視頻要什麼格式的 發布:2024-12-23 11:05:56 瀏覽:594
百度雲伺服器怎樣 發布:2024-12-23 11:02:21 瀏覽:644