📄 appsettinglist.c
字号:
/*-------------------------------------------------------------------------------
// appSettingList
// appSettingList
// Create by jsguo 2005.10.3
--------------------------------------------------------------------------------*/
#include "../inc/nucleus.h"
#include "../inc/winconfig.h"
#include "MMI.h"
#include "../inc/windows.h"
#include "../inc/nucleus.h"
#include "../inc/nu_sd.h"
extern NU_SERIAL_PORT port;
//------------------------------------------------------------------------------
// 全局变量
int gnShowMenu_SettingList;
int gnselectItem_SettingList ;
LRESULT CALLBACK VMSettingListProc(HWND,UINT,WPARAM,LPARAM);
InitMWindow initMySettingList;
Form gMyFormSettingList;
CloseMWindow closeMySettingList;
int SetSettingList(InitMWindow init,CloseMWindow close,Form FormDocumentList)
{
initMySettingList=init;
initMySettingList();
closeMySettingList=close;
gMyFormSettingList=FormDocumentList;
return 1;
}
int MMI_GetSettingSelectItem()
{
return gnselectItem_SettingList;
}
int WINAPI VMSettingListMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static char szAppName[]="SettingApp";
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = (WNDPROC)VMSettingListProc;
wndclass.cbClsExtra =0;
wndclass.cbWndExtra =0;
wndclass.hInstance =0;
wndclass.hIcon =0;
wndclass.hCursor =0;
wndclass.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName =NULL;
wndclass.lpszClassName = szAppName;
RegisterClass(&wndclass);
hwnd=CreateWindowEx(0L,
szAppName,
"Setting",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT,
CW_USEDEFAULT,
MAINFRAME_WIDTH_DEFAULT,
MAINFRAME_HEIGHT_DEFAULT,
NULL,
NULL,
NULL,
NULL);
gnselectItem_SettingList=0;
ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&msg,NULL,0,0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
SLIDER_Obj gScrollBarSetting={0x40c1ff,0xffff00,2,5,MAINFRAME_HEIGHT_DEFAULT-25,5,5};
LRESULT CALLBACK VMSettingListProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect1;
int i,keyvalue,y;
int nSliderValue=0;
HBRUSH hBrush,hBgBrush;
KeyEvent event;
switch (iMsg) {
case WM_CREATE:
gnShowMenu_SettingList = 1;
break;
case WM_PAINT:
hBrush = CreateSolidBrush(COLOR_SELECT);//0xa3138);//GetSysColor(COLOR_MENU));
hBgBrush = CreateSolidBrush(COLOR_NORMAL);
hdc=BeginPaint(hwnd,&ps);
if((gMyFormSettingList.MenuSize-2)!=0)
nSliderValue=(gScrollBarSetting.slnEndX-gScrollBarSetting.slnStartX)/(gMyFormSettingList.MenuSize-2);
else
nSliderValue=gScrollBarSetting.slnEndX;
rect1.left = 10;
rect1.right = MAINFRAME_WIDTH_DEFAULT;
rect1.top = 0;
rect1.bottom = LIST_HEIGHT_DEFAULT;
for( i = 0; i < gMyFormSettingList.MenuSize; i++)
{
if(gnselectItem_SettingList == i)
{
FillRect(hdc,&rect1,hBrush);
}
else
{
FillRect(hdc,&rect1,hBgBrush);
}
if(gnselectItem_SettingList <LIST_DATA_DEFAULT)
{
DrawText(hdc,gMyFormSettingList.MenuList[i].MenuName,-1,&rect1,
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
rect1.top += LIST_HEIGHT_DEFAULT+1;
rect1.bottom += LIST_HEIGHT_DEFAULT+1;
}
else
{
for(y=6;rect1.bottom<(MAINFRAME_HEIGHT_DEFAULT-MENU_HEIGHT_DEFAULT);rect1.bottom+=LIST_HEIGHT_DEFAULT+1,y--)
{
rect1.top=rect1.bottom-LIST_HEIGHT_DEFAULT;
if(y == 0)
{
FillRect(hdc,&rect1,hBrush);
}
else
{
FillRect(hdc,&rect1,hBgBrush);
}
DrawText(hdc,gMyFormSettingList.MenuList[gnselectItem_SettingList-y].MenuName,-1,&rect1,
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
}
i = gMyFormSettingList.MenuSize;
}
}
gScrollBarSetting.slnCurrentX=nSliderValue*gnselectItem_SettingList;
DisplaySlider(hwnd,gScrollBarSetting);
DeleteObject(hBgBrush);
DeleteObject(hBrush);
EndPaint(hwnd,&ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_KEYUP:
keyvalue = wParam - 49;
if(keyvalue == KEY_CANCEL)
{
if(closeMySettingList != NULL)
{
closeMySettingList();
}
PostMessage(hwnd,WM_CLOSE,0,0);
}
//if((keyvalue >= 0) && (keyvalue <= 4)) // 方向键
if((keyvalue == KEY_UP) || (keyvalue == KEY_DOWN)||(keyvalue == KEY_OK))
{
if(gnShowMenu_SettingList==1) // 显示菜单
{
gnselectItem_SettingList = gMyFormSettingList.CurrentMenuItem;
//if((keyvalue == 4) || (keyvalue == KEY_LEFT) )//|| (keyvalue == KEY_RIGHT))
if((keyvalue == KEY_OK))
{
event = NULL;
event = gMyFormSettingList.MenuList[gnselectItem_SettingList].event;
if(event != NULL)
{
event(iMsg, wParam, lParam);
return 1;
}
}
// 按下方向键,重绘
if(keyvalue == KEY_DOWN)
gnselectItem_SettingList ++;
else if (keyvalue == KEY_UP)
gnselectItem_SettingList --;
if(gnselectItem_SettingList < 0)
gnselectItem_SettingList = gMyFormSettingList.MenuSize - 1;
else if(gnselectItem_SettingList >= gMyFormSettingList.MenuSize)
gnselectItem_SettingList = 0;
gMyFormSettingList.CurrentMenuItem = gnselectItem_SettingList ;
PostMessage(hwnd,WM_PAINT,0,0);
}
}
break;
default:
return DefWindowProc(hwnd,iMsg,wParam,lParam);
}
return (0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -