你要啥类型的啊。。
下面这个行不行啊?是一个完整的程序 在窗口上画了一个石英钟
using System;
using SystemReflection;
using SystemWindowsForms;
using SystemRuntimeInteropServices;
using LPCTSTR = SystemString;
using ATOM = SystemUInt16;
using WORD = SystemUInt16;
using BYTE = SystemUInt16;
using DWORD = SystemUInt32;
using WPARAM = SystemUInt32;
using UINT = SystemUInt32;
using LRESULT = SystemInt32;
using LPARAM = SystemInt32;
using LPVOID = SystemInt32;
using HRESULT = SystemInt32;
using BOOL = SystemInt32;
using LPSIZE = SystemInt32;
using LPPOINT = SystemInt32;
using HWND = SystemIntPtr;
using HINSTANCE = SystemIntPtr;
using HICON = SystemIntPtr;
using HCURSOR = SystemIntPtr;
using HBRUSH = SystemIntPtr;
using HMENU = SystemIntPtr;
using HDC = SystemIntPtr;
using HGDIOBJ = SystemIntPtr;
namespace AnalogClock
{
class Program
{
static Int32 Main(String[] args)
{
ConsoleTitle = "Analog Clock";
ShowWindow(FindWindow(null, ConsoleTitle), SW_HIDE);
hInst = MarshalGetHINSTANCE(AssemblyGetExecutingAssembly()GetModules()[0]);
MSG msg;
WindowRegister(hInst);
if (1 > InitInstance(hInst, SW_SHOW)) return 0;
while (0 != GetMessage(out msg, HWNDZero, 0, 0))
{
TranslateMessage(out msg);
DispatchMessage(out msg);
}
return (Int32)msgwParam;
}
private static ATOM WindowRegister(HINSTANCE hInstance)
{
WndMainProc = new WNDPROC(WndProc);
WNDCLASSEX wnd;
wndcbClsExtra = 0;
wndcbSize = (UInt32)MarshalSizeOf(typeof(WNDCLASSEX));
wndcbWndExtra = 0;
wndhbrBackground = hbrWhite;
wndhCursor = CursorsArrowHandle;
wndhIcon = ResourceAppHandle;
wndhIconSm = ResourceAppHandle;
wndhInstance = hInstance;
wndlpfnWndProc = WndMainProc;
wndlpszClassName = "AnalogClock";
wndlpszMenuName = null;
wndstyle = CS_HREDRAW | CS_VREDRAW;
return RegisterClassEx(ref wnd);
}
private static BOOL InitInstance(HINSTANCE hInstance, UInt32 nCmdShow)
{
Int32 xScreen = (GetSystemMetrics(SM_CXSCREEN) - 300) >> 1;
Int32 yScreen = (GetSystemMetrics(SM_CYSCREEN) - 300) >> 1;
HWND hWndMain = CreateWindowEx(WS_EX_TOPMOST, "AnalogClock", "Analog Clock",
WS_OVERLAPPEDWINDOW,
xScreen, yScreen, 300, 300, HWNDZero, HWNDZero, hInstance, 0);
if (HWNDZero == hWndMain) return FALSE;
ShowWindow(hWndMain, nCmdShow);
UpdateWindow(hWndMain);
return TRUE;
}
private static LRESULT WndProc(HWND hWnd, UInt32 uMsg, WPARAM wParam, LPARAM lParam)
{
BOOL fChange;
HDC hdc;
PAINTSTRUCT ps;
SYSTEMTIME st;
switch (uMsg)
{
case WM_CREATE:
SetTimer(hWnd, ID_TIMER, 10, null);
GetLocalTime(out st);
stPrevious = st;
break;
case WM_SIZE:
cxClient = LOWORD(lParam); cyClient = HIWORD(lParam);
break;
case WM_TIMER:
GetLocalTime(out st);
fChange = stwHour != stPreviouswHour ||
stwMinute != stPreviouswMinute ||
stwSecond != stPreviouswSecond TRUE : FALSE;
hdc = GetDC(hWnd);
SetIsotropic(hdc);
SelectObject(hdc, hpnWhite);
DrawHands(hdc, ref stPrevious, fChange);
SelectObject(hdc, hpnBlack);
DrawHands(hdc, ref st, TRUE);
ReleaseDC(hWnd, hdc);
stPrevious = st;
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, out ps);
SetIsotropic(hdc);
DrawClock(hdc);
DrawHands(hdc, ref stPrevious, TRUE);
EndPaint(hWnd, out ps);
break;
case WM_DESTROY:
KillTimer(hWnd, ID_TIMER);
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return 0;
}
private static void SetIsotropic(HDC hdc)
{
SetMapMode(hdc, (Int32)MM_ISOTROPIC);
SetWindowExtEx(hdc, 1000, 1000, 0);
SetViewportExtEx(hdc, cxClient >> 1, -cyClient >> 1, 0);
SetViewportOrgEx(hdc, cxClient >> 1, cyClient >> 1, 0);
}
private static void RotatePoint(POINT[] pt, Int32 iNum, Int32 iAngle)
{
Int32 i;
POINT ptTemp;
for (i = 0; i < iNum; i++)
{
ptTempx = (Int32)(pt[i]x MathCos(TWOPI iAngle / 3600) +
pt[i]y MathSin(TWOPI iAngle / 3600));
ptTempy = (Int32)(pt[i]y MathCos(TWOPI iAngle / 3600) -
pt[i]x MathSin(TWOPI iAngle / 3600));
pt[i]x = ptTempx; pt[i]y = ptTempy;
}
}
private static void DrawClock(HDC hdc)
{
Int32 iAngle;
POINT[] pt = new POINT[3];
for (iAngle = 0; iAngle < 360; iAngle += 6)
{
pt[0]x = 0; pt[0]y = 900;
RotatePoint(pt, 1, iAngle);
pt[2]x = 0 < iAngle % 5 33 : 100; pt[2]y = pt[2]x;
pt[0]x -= pt[2]x >> 1; pt[0]y -= pt[2]y >> 1;
pt[1]x = pt[0]x + pt[2]x; pt[1]y = pt[0]y + pt[2]y;
SelectObject(hdc, hbrBlack);
Ellipse(hdc, pt[0]x, pt[0]y, pt[1]x, pt[1]y);
}
}
private static void DrawHands(HDC hdc, ref SYSTEMTIME pst, BOOL fChange)
{
Int32 i;
Int32[] iAngle = new Int32[4] {
(Int32)(3600 pstwHour / 120 + 300 pstwMinute / 600),
(Int32)(3600 pstwMinute / 600 + 60 pstwSecond / 60),
(Int32)(3600 pstwSecond / 600 + 60 pstwMilliseconds / 1000), 0 };
POINT[,] pt = new POINT[4, 5];
iAngle[3] = iAngle[2];
pt[0, 0]x = 0; pt[0, 0]y = -150;
pt[0, 1]x = 100; pt[0, 1]y = 0;
pt[0, 2]x = 0; pt[0, 2]y = 600;
pt[0, 3]x = -100; pt[0, 3]y = 0;
pt[0, 4]x = 0; pt[0, 4]y = -150;
pt[1, 0]x = 0; pt[1, 0]y = -200;
pt[1, 1]x = 50; pt[1, 1]y = 0;
pt[1, 2]x = 0; pt[1, 2]y = 800;
pt[1, 3]x = -50; pt[1, 3]y = 0;
pt[1, 4]x = 0; pt[1, 4]y = -200;
pt[2, 0]x = 0; pt[2, 0]y = -150;
pt[2, 1]x = 0; pt[2, 1]y = 0;
pt[2, 2]x = 0; pt[2, 2]y = 0;
pt[2, 3]x = 0; pt[2, 3]y = 0;
pt[2, 4]x = 0; pt[2, 4]y = 800;
pt[3, 0]x = -10; pt[3, 0]y = 0;
pt[3, 1]x = 0; pt[3, 1]y = -10;
pt[3, 2]x = 10; pt[3, 2]y = 0;
pt[3, 3]x = 0; pt[3, 3]y = 10;
pt[3, 4]x = -10; pt[3, 4]y = 0;
for (i = 0 < fChange 0 : 2; i < 4; i++)
{
POINT[] ptTmp = new POINT[5];
ptTmp[0] = pt[i, 0]; ptTmp[1] = pt[i, 1];
ptTmp[2] = pt[i, 2]; ptTmp[3] = pt[i, 3];
ptTmp[4] = pt[i, 4];
RotatePoint(ptTmp, 5, iAngle[i]);
Polyline(hdc, ptTmp, 5);
}
}
private static Int32 LOWORD(Int32 i) { return i & 0xFFFF; }
private static Int32 HIWORD(Int32 i) { return i >> 0x10; }
private static Int32 cxClient, cyClient;
private static HINSTANCE hInst;
private static SYSTEMTIME stPrevious;
private static WNDPROC WndMainProc;
private const UINT ID_TIMER = 1;
private const Double TWOPI = 2 MathPI;
private static HBRUSH hbrBlack = GetStockObject(BLACK_BRUSH);
private static HBRUSH hbrWhite = GetStockObject(WHITE_BRUSH);
private static HBRUSH hpnBlack = GetStockObject(BLACK_PEN);
private static HBRUSH hpnWhite = GetStockObject(WHITE_PEN);
private const Int32 TRUE = 1, FALSE = 0;
private const UINT
WS_OVERLAPPED = 0x00000000, WS_BORDER = 0x00800000, WS_DLGFRAME = 0x00400000,
WS_SYSMENU = 0x00080000, WS_THICKFRAME = 0x00040000, WS_MINIMIZEBOX = 0x00020000,
WS_MAXIMIZEBOX = 0x00010000, WS_CAPTION = WS_BORDER | WS_DLGFRAME,
WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW;
private const UINT WM_CREATE = 0x0001, WM_DESTROY = 0x0002,
WM_SIZE = 0x0005, WM_PAINT = 0x000F, WM_TIMER = 0x0113;
private const UINT WS_EX_TOPMOST = 0x00000008;
private const UINT CS_VREDRAW = 0x0001, CS_HREDRAW = 0x0002;
private const UINT SW_HIDE = 0, SW_SHOW = 5;
private const UINT MM_ISOTROPIC = 7;
private const Int32 SM_CXSCREEN = 0, SM_CYSCREEN = 1;
private const Int32 WHITE_BRUSH = 0, BLACK_BRUSH = 4, WHITE_PEN = 6, BLACK_PEN = 7;
[StructLayout(LayoutKindSequential)]
private struct MSG
{
public HWND hwnd;
public UINT message;
public UINT wParam;
public LPARAM lParam;
public UINT time;
public POINT pt;
}
[StructLayout(LayoutKindSequential)]
private struct WNDCLASSEX
{
public UInt32 cbSize;
public UInt32 style;
public WNDPROC lpfnWndProc;
public Int32 cbClsExtra;
public Int32 cbWndExtra;
public HINSTANCE hInstance;
public HICON hIcon;
public HCURSOR hCursor;
public HBRUSH hbrBackground;
public String lpszMenuName;
public String lpszClassName;
public HICON hIconSm;
}
[StructLayout(LayoutKindSequential)]
private struct SYSTEMTIME
{
public WORD wYear;
public WORD wMonth;
public WORD wDayOfWeek;
public WORD wDay;
public WORD wHour;
public WORD wMinute;
public WORD wSecond;
public WORD wMilliseconds;
}
[StructLayout(LayoutKindSequential)]
private struct PAINTSTRUCT
{
public HDC hdc;
public BOOL fErase;
public RECT rcPaint;
public BOOL fRestore;
public BOOL fIncUpdate;
[MarshalAs(UnmanagedTypeByValArray, SizeConst = 32)]
public BYTE[] rgbReserved;
}
[StructLayout(LayoutKindSequential)]
private struct RECT
{
public Int32 left;
public Int32 top;
public Int32 right;
public Int32 bottom;
}
[StructLayout(LayoutKindSequential)]
private struct POINT
{
public Int32 x;
public Int32 y;
}
[StructLayout(LayoutKindSequential)]
private struct SIZE
{
public Int32 cx;
public Int32 cy;
}
private delegate Int32 WNDPROC(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
private delegate void TIMERPROC(IntPtr hwnd, UINT uMsg, UINT idEvent, UINT dwTime);
[DllImport("user32dll")]
private static extern BOOL GetMessage(
out MSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax);
[DllImport("user32dll")]
private static extern BOOL TranslateMessage(out MSG lpMsg);
[DllImport("user32dll")]
private static extern Int32 DispatchMessage(out MSG lpMsg);
[DllImport("user32dll")]
private static extern ATOM RegisterClassEx(ref WNDCLASSEX lpwcx);
[DllImport("user32dll")]
private static extern BOOL ShowWindow(HWND hWnd, UInt32 nCmdShow);
[DllImport("user32dll")]
private static extern BOOL UpdateWindow(HWND hWnd);
[DllImport("user32dll")]
private static extern HWND CreateWindowEx(
DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName,
DWORD dwStyle, Int32 x, Int32 y, Int32 nWidth, Int32 nHeight,
HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam);
[DllImport("user32dll")]
private static extern LRESULT DefWindowProc(HWND hWnd, UInt32 Msg, WPARAM wParam, LPARAM lParam);
[DllImport("user32dll")]
private static extern Int32 GetSystemMetrics(Int32 nIndex);
[DllImport("user32dll")]
private static extern UInt32 SetTimer(HWND hwnd, UINT idTimer, UINT uTimeout, TIMERPROC tmprc);
[DllImport("user32dll")]
private static extern BOOL KillTimer(HWND hwnd, UINT uIDEvent);
[DllImport("user32dll")]
private static extern HDC GetDC(HWND hWnd);
[DllImport("user32dll")]
private static extern HRESULT ReleaseDC(HWND hWnd, HDC hDC);
[DllImport("user32dll")]
private static extern HDC BeginPaint(HWND hwnd, out PAINTSTRUCT lpPaint);
[DllImport("user32dll")]
private static extern BOOL EndPaint(HWND hwnd, out PAINTSTRUCT lpPaint);
[DllImport("user32dll")]
private static extern void PostQuitMessage(Int32 nExitCode);
[DllImport("user32dll")]
private static extern HWND FindWindow(LPCTSTR lpClassName, LPCTSTR lpWindowName);
[DllImport("gdi32dll")]
private static extern HGDIOBJ GetStockObject(Int32 fnObject);
[DllImport("gdi32dll")]
private static extern Int32 SetMapMode(HDC hdc, Int32 fnMapMode);
[DllImport("gdi32dll")]
private static extern BOOL SetWindowExtEx(HDC hdc, Int32 nXExtent, Int32 nYExtent, LPSIZE lpSize);
[DllImport("gdi32dll")]
private static extern BOOL SetViewportExtEx(HDC hdc, Int32 nXExtent, Int32 nYExtent, LPSIZE lpSize);
[DllImport("gdi32dll")]
private static extern BOOL SetViewportOrgEx(HDC hdc, Int32 X, Int32 Y, LPPOINT lpPoint);
[DllImport("gdi32dll")]
private static extern HGDIOBJ SelectObject(HDC hdc, HGDIOBJ hgdiobj);
[DllImport("gdi32dll")]
private static extern BOOL DeleteObject(HGDIOBJ hObject);
[DllImport("gdi32dll")]
private static extern BOOL Ellipse(
HDC hdc, Int32 nLeftRect, Int32 nTopRect, Int32 nRightRect, Int32 nBottomRect);
[DllImport("gdi32dll")]
private static extern BOOL Polyline(HDC hdc, POINT[] lppt, Int32 cPoints);
[DllImport("kernel32dll")]
private static extern void GetLocalTime(out SYSTEMTIME lpSystemTime);
}
}
我们在写样式的时候,可能一个app内的颜色,比如#00ff00,假设这个颜色我用了100次,穿插写在不同的页面里。当需要修改这个主题的时候,会让人抓狂。
所以我们可以使用变量来优化。
在html, css里面,它原始的定义方式及使用方法是这样的
其中,:root是根元素选择器,也就是<html>元素。在这里面定义的变量,可以在整个页面进行使用。
使用的时候,用var()函数进行调用。
注意:约定变量名须以两个连字符'--'开头
在小程序中,用法基本也是一样的:
我们在wxss页面中进行定义
注意,page选择器是选中整个页面,前面是没有''号的。这是wxss系统自带的选择器。可以看到,用法和css原始用法差别不大。
你也可以在wxml里面直接使用!
这个wxss变量,既可以在每个页面mypagewxss里面的page里声明,
,就能在所有页面里使用。
您好,微信小程序从数据库中获取**分类词条并显示的方法如下:
1 首先,需要在微信小程序中连接到数据库,可以使用MySQL、SQL Server等数据库。
2 然后,在数据库中创建一个表,用于存储**分类词条。
3 接着,在微信小程序中使用SQL语句,从数据库中查询**分类词条,并将查询结果显示在小程序中。
4 最后,在小程序中设置一个搜索框,用户可以输入关键字搜索**分类词条,从而快速定位**分类词条。
以上就是微信小程序从数据库中获取**分类词条并显示的方法,希望能够帮助您。
以上就是关于求c#小程序一段,要交作业滴,最好有界面,有算法滴,有的给个现成的就行,给的追加高分,拜托了全部的内容,包括:求c#小程序一段,要交作业滴,最好有界面,有算法滴,有的给个现成的就行,给的追加高分,拜托了、小程序wxss;css中使用变量、微信小程序如何从数据库中得到电影分类词条并显示等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)