📄 list.c
字号:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
#include <minigui/control.h>
#include <minigui/mgext.h>
#include <minigui/mywindows.h>
#include "list.h"
#include "listdraw.h"
static int MultiPage;//多页标志,如果记录大于20行就让MultiPage增加1,根据这个标志来写滑动条函数,也可以判断提供的数据的多少,超过200个
//表明超过了一页,这时可以使用滑动条。
static int * dataaddr;//主程序给的数据首地址
static void ScroBarProc(HWND hWnd, int id, int nc, DWORD add_data);//滑动条的回调函数
static void inintctrl(HWND hWnd);//初始化所有控件
static void initList(HWND hWnd);//初始化list窗口不动的内容例如标签、方框等等.该函数在paint中执行
static void CtrlAdd(const char * spClassName,
const char * spCaption,
DWORD dwStyle,
DWORD dwExStyle,
int id,
int x,
int y,
int w,
int h,
HWND hParentWnd,
DWORD dwAddData,
NOTIFPROC PROC
);
//自定义彩色文本控件函数
static int ColorEditConProc (HWND hwnd, int message, WPARAM wParam, LPARAM lParam);
static BOOL RegisterColorEditControl (void);
static void UnregisterColorEditControl (void);
/**********************************************************************
**函数名:static void ScroBarProc(HWND hWnd, int id, int nc, DWORD add_data)
**功能:滑动条的回调函数
**返回值:无
**作者:陈永奎
**时间:2008.04.23
***********************************************************************/
static void ScroBarProc(HWND hWnd, int id, int nc, DWORD add_data)
{
unsigned char sliderpos=20;
int i;
sliderpos=SendMessage(hWnd,TBM_GETPOS,0,0);
if((sliderpos>=0)&&(sliderpos<=20))
{
if((TBN_CHANGE==nc)&&(MultiPage>=1))
{
if(20-sliderpos<=MultiPage)
{
printf("sliderpos=%d\n",sliderpos);
printf("MultiPage=%d\n",MultiPage);
//找到要绘制的数据的首行数据地址,循环多次利用链表中记录的地址寻找
for(i=0;i<20-sliderpos;i++)
{
//dataaddr=dataaddr->nextaddr;
}
//下面开始填充该地址开始的数据
}
}
}
}
/**********************************************************************
**函数名:static void inintctrl(HWND hWnd)
**功能:初始化“列表”窗口中的所有控件
**参数:"列表"窗口的句柄
**返回值:无
**作者:陈永奎
**时间:2008.04.23
***********************************************************************/
static void inintctrl(HWND hWnd)
{
CtrlAdd(CTRL_TRACKBAR, "",
WS_VISIBLE | TBS_NOTIFY | TBS_NOTICK | TBS_VERTICAL,
WS_NONE,
ID_Scro,
ScroXorg, ScroYorg, ScroWidth, ScroHeight,
hWnd, 0, ScroBarProc);
SendMessage(GetDlgItem(hWnd,ID_Scro),TBM_SETRANGE,0,20);
SendMessage(GetDlgItem(hWnd,ID_Scro),TBM_SETPOS,20,0);
}
/**********************************************************************
**函数名:static void initList(HWND hWnd)
**功能:初始化“列表”窗口中的所有自己画的方框,此函数在MSG_PAINT中执行
**参数:"趋势"窗口的句柄
**返回值:无
**作者:陈永奎
**时间:2008.04.23
***********************************************************************/
static void initList(HWND hWnd)
{
RECT ListVal[10];
char * ListHead[9]={"时 间","心 率","体 温","脉搏氧","呼吸率","收缩压","舒张压","平均压","脉 搏"};
struct label LHRect[9];
int i=0;
HDC hdc;
/*****************************初始化标题头******************************/
hdc=GetClientDC(hWnd);
for(i=0;i<9;i++)
{
LHRect[i].text=ListHead[i];
LHRect[i].bkclor=COLOR_black;
LHRect[i].fontcolor=COLOR_cyan;
LHRect[i].framcolor=COLOR_black;
LHRect[i].Height=LHHeight;
LHRect[i].Width=LHWidth;
LHRect[i].Xorg=FirstLHXorg+i*(ListPerWidth+ListGap);
LHRect[i].Yorg=FirstLHYorg;
LDrawLabel(hdc,LHRect[i],'H');
}
ReleaseDC(hdc);
/***************************初始化标题头结束***************************/
/*****************************初始化下面的十个方框**********************/
hdc=GetClientDC(hWnd);
for(i=0;i<10;i++)
{
ListVal[i].top=FirstLHYorg+LHHeight+2;
ListVal[i].bottom=ListVal[i].top+ListPerHeight;
ListVal[i].left=ListGap+i*(ListPerWidth+ListGap);
ListVal[i].right=ListVal[i].left+ListPerWidth;
LDrawRect(hdc,ListVal[i],COLOR_cyan);
}
ReleaseDC(hdc);
/*****************************初始化下面的十个方框结束******************/
/****************初始化滑动条两边的箭头*****************/
hdc=GetClientDC(hWnd);
SetPenColor(hdc,COLOR_cyan);
Rectangle(hdc,ScroXorg,ScroYorg-ScroWidth,ScroXorg+ScroWidth-1,ScroYorg);
//画那个方框中的箭头(上箭头)
MoveTo(hdc, ScroXorg+(ScroWidth>>2), ScroYorg-(ScroWidth>>2));
LineTo(hdc, ScroXorg+3*(ScroWidth>>2), ScroYorg-(ScroWidth>>2));
LineTo(hdc, ScroXorg+2*(ScroWidth>>2), ScroYorg-(ScroWidth>>2)*3);
LineTo(hdc, ScroXorg+(ScroWidth>>2), ScroYorg-(ScroWidth>>2));
//下方框和下箭头
Rectangle(hdc,ScroXorg,ScroYorg+ScroHeight-1,ScroXorg+ScroWidth-1,ScroYorg+ScroHeight+ScroWidth);
MoveTo(hdc,ScroXorg+(ScroWidth>>2), ScroYorg+ScroHeight-1+(ScroWidth>>2));
LineTo(hdc, ScroXorg+(ScroWidth>>2)*3, ScroYorg+ScroHeight-1+(ScroWidth>>2));
LineTo(hdc, ScroXorg+(ScroWidth>>2)*2, ScroYorg+ScroHeight-1+(ScroWidth>>2)*3);
LineTo(hdc,ScroXorg+(ScroWidth>>2), ScroYorg+ScroHeight-1+(ScroWidth>>2));
ReleaseDC(hdc);
/****************初始化滑动条两边的箭头结束*************/
}
/**********************************************************************
**函数名:static void CtrlAdd(const char * spClassName,
const char * spCaption,
DWORD dwStyle,
DWORD dwExStyle,
int id,
int x,
int y,
int w,
int h,
HWND hParentWnd,
DWORD dwAddData,
NOTIFPROC PROC
)
**功能:添加控件函数,包括该控件的回调函数名称,整合了两个函数
**参数:控件的各种参数加上该控件的回调函数名称
**返回值:无
**作者:陈永奎
**时间:2008.03.31
***********************************************************************/
static void CtrlAdd(const char * spClassName,
const char * spCaption,
DWORD dwStyle,
DWORD dwExStyle,
int id,
int x,
int y,
int w,
int h,
HWND hParentWnd,
DWORD dwAddData,
NOTIFPROC PROC
)
{
HWND hwnd;
hwnd=CreateWindowEx(spClassName,spCaption,dwStyle,dwExStyle,id,x,y,w,h,hParentWnd,dwAddData);
SetNotificationCallback (hwnd,PROC);
}
/**********************************************************************
**函数名:static int ListProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
**功能:“趋势”窗口的总的回调函数
**参数:主回调函数所有参数
**返回值:无
**作者:陈永奎
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -