⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 project.c

📁 一个minigui 工程框架,需要windows 下的minigui 开发环境
💻 C
📖 第 1 页 / 共 3 页
字号:
	Grid_width  = GetLongVal(objstring,&pos);
	
	
	//// grid size.cy.
	
	index = GetIndexInformation(objstring,&pos);
	if(index._Type!=0) 
	{
		nReturn = FALSE; 
		goto FAILED;
	}
	Grid_height  = GetLongVal(objstring,&pos);
	
	
	// backgroundcolor.
	index = GetIndexInformation(objstring,&pos);
	if(index._Type!=0) 
	{ 
		nReturn = FALSE; 
		goto FAILED;
	}
	dwBackgroundColor  = GetLongVal(objstring,&pos);
	
	
	// status.
	index = GetIndexInformation(objstring,&pos);
	if(index._Type!=0)  
	{ 
		nReturn = FALSE; 
		goto FAILED;
	}
	bStatus  =(unsigned char) GetLongVal(objstring,&pos);
	
	
	// image name.
	index = GetIndexInformation(objstring,&pos);
	if(index._Type!=1) 
	{
		nReturn = FALSE;
		goto FAILED;
	}	 
	ImageItem_ImageName = GetStringVal(objstring,index._Length,&pos,0);
//	assert(ImageItem_ImageName);
	
	
	// image fore color.
	index = GetIndexInformation(objstring,&pos);
	if(index._Type!=0) 
	{ 
		nReturn = FALSE;
		goto FAILED;
	}
	ImageItem_dwForeColor  = GetLongVal(objstring,&pos);
	
	
	// image back color.
	index = GetIndexInformation(objstring,&pos);
	if(index._Type!=0)  
	{ 
		nReturn = FALSE; 
		goto FAILED;
	}
	ImageItem_dwBackColor  = GetLongVal(objstring,&pos);
	
	
	// image status.
	index = GetIndexInformation(objstring,&pos);
	if(index._Type!=0)  
	{
		nReturn = FALSE;
		goto FAILED;
	}
	ImageItem_bStatus  =(unsigned char) GetLongVal(objstring,&pos);
	
	
	// image transp color
	index = GetIndexInformation(objstring,&pos);
	if(index._Type!=0)  
	{ 
		nReturn = FALSE; 
		goto FAILED;
	}
	ImageItem_dwTransparenceColor  = GetLongVal(objstring,&pos);
	
	
	// page name
	
	index = GetIndexInformation(objstring,&pos);
	if(index._Type!=1) 
	{ 
		nReturn = FALSE; 
		goto FAILED;
	}
	szPageName = GetStringVal(objstring,index._Length,&pos,0);
//	assert(szPageName);
	
	
	
	index = GetIndexInformation(objstring,&pos);
	if(index._Type!=0) 
	{
		nReturn = FALSE;
		goto FAILED;
	}
	Comm_Type  =(unsigned int) GetLongVal(objstring,&pos);
	
	
	// feedback type
	index = GetIndexInformation(objstring,&pos);
	if(index._Type!=0)  
	{ 
		nReturn = FALSE;
		goto FAILED;
	}
	feedback_type = (int) GetLongVal(objstring,&pos);
	
	
	// page id.
	index = GetIndexInformation(objstring,&pos);
	if(index._Type!=0) 
	{ 
		nReturn = FALSE; 
		goto FAILED;
	}
	nID = (int) GetLongVal(objstring,&pos);
	
	
	
	// delay.
	index = GetIndexInformation(objstring,&pos);
	if(index._Type!=0)  
	{ 
		nReturn = FALSE; 
		goto FAILED;
	}
	delay = (int) GetLongVal(objstring,&pos);
	
	
	// group id 
	index = GetIndexInformation(objstring,&pos);
	if(index._Type!=1) 
	{ 
		nReturn = FALSE; 
		goto FAILED;
	}	 
	groupid = GetStringVal(objstring,index._Length,&pos,0);
//	assert(groupid);
	
	// fashion.
	index = GetIndexInformation(objstring,&pos);
	if(index._Type==0)  
	{ 
		fashion = (int) GetLongVal(objstring,&pos);
	}

	
	Page_Initialize2(subpage_pointer,
		Position_left,
		Position_top,
		Position_right,
		Position_bottom,					
		bStyle,	
		Grid_width,
		Grid_height,
		dwBackgroundColor,
		bStatus,
		ImageItem_ImageName,	
		ImageItem_dwForeColor,	
		ImageItem_dwBackColor,	
		ImageItem_bStatus,	
		ImageItem_dwTransparenceColor,
		szPageName,
		Comm_Type,
		feedback_type,
		nID,
		delay,
		groupid,
		fashion
		);
	if(subpage_pointer && page_pointer)
		page_add_subpage(page_pointer,subscript,subpage_pointer);
	
FAILED:
	if(ImageItem_ImageName)
		free (ImageItem_ImageName);
	if(szPageName)
		free (szPageName);
	if(groupid)
		free (groupid);

	return nReturn;
}
HWND CreatePage(Page* page_pointer)
{
	WidgetList prv,wl;
	Page* parent_page;
	void* widget_p;
	int x,y,w,h;
	WinInfo* info;
	if(!page_pointer)
		return 0;
	parent_page=page_pointer->m_pParentPage;
	x = page_pointer->m_rPosition.left;
	y = page_pointer->m_rPosition.top;
	w = page_pointer->m_rPosition.right - x;
	h = page_pointer->m_rPosition.bottom -y;
	if(page_pointer->m_bStyle==MAIN_PAGE)
	{	
		page_pointer->m_grPageID = CreateWindow(PAGE_MINIGUI,"",WS_VISIBLE | WS_CHILD ,0,x,y,w,h,g_miscii.g_wndMain,0);		
	}
	else
	{
		page_pointer->m_grPageID = CreateWindow(PAGE_MINIGUI,"",WS_VISIBLE | WS_CHILD ,0,x,y,w,h,parent_page->m_grPageID,0);		
	}


	info = (WinInfo*)malloc(sizeof(struct _WinInfo));
	memset((void*)info,0,sizeof(struct _WinInfo));
	info->id = page_pointer->m_grPageID;
	if(page_pointer->m_bStyle==MAIN_PAGE)
		info->type = PAGE_X;
	else
		info->type = SUBPAGE_X;
	info->obj = (void*)page_pointer;
	PushInfo(info);

	wl = page_pointer->m_wlWidgetList;
	prv = wl;

	while(wl)
	{
		widget_p = wl->widget_pointer;
		switch(wl->widget_type)
		{
		case BUTTON_X:
			{
				if(page_pointer->m_bStyle==MAIN_PAGE)	
					CreateButton((Button*)widget_p,0);		
				else
					CreateButton((Button*)widget_p,page_pointer);
			}
			break;
		case SUBPAGE_X:
			CreatePage(&g_list[wl->subpage_pos]);
			break;
		case BORDER_X:
//			CreateBorder((Border*)widget_p,page_pointer);
			break;
		case LABEL_X:
			CreateLabel((Label*)widget_p,page_pointer);
			break;
		case IMAGE_X:
			CreateImage((Image*)widget_p,page_pointer);
			break;
		default:
			break;
		}
		
		prv = wl;
		wl = prv->next;		
	}


	return page_pointer->m_grPageID;
}


HWND CreateImage(Image* image_p,Page* page_p)
{
	int x,y,w,h;
	HWND  id;
	HWND pid = 0;
	WinInfo* info = 0;
	Page* pPage = 0;
	pPage = (Page*)image_p->m_pParentPage;
	if(!image_p)
		return 0;
	if(image_p->m_iiImage.szImageName == NULL)
		return 0;

	pid = pPage->m_grPageID;
	x = image_p->m_rPosition.left;
	y = image_p->m_rPosition.top;
	w = image_p->m_rPosition.right -  image_p->m_rPosition.left;
	h = image_p->m_rPosition.bottom -  image_p->m_rPosition.top;

	id 	= CreateWindow(IMAGE_MINIGUI,"",WS_VISIBLE | WS_CHILD ,0,x,y,w,h,pPage->m_grPageID,0);


	image_p ->m_grImageID = id;
	
	info = (WinInfo*)malloc(sizeof(struct _WinInfo));
	memset((void*)info,0,sizeof(struct _WinInfo));
	info->id = id;
	info->type = IMAGE_X;
	info->obj = (void*)image_p;
	PushInfo(info);

	ShowWindows(id);
	if(debug_flag)
		printf("Create Image wid : %d !\n",id);
	return id;
}

HWND CreateLabel(Label* label_p,Page* page_p)
{
	int x,y,w,h;
	HWND  id;
	HWND pid = 0;
	WinInfo* info = 0;
	Page* pPage = 0;
	pPage = (Page*)label_p->m_pParentPage;
	if(!label_p || !pPage)
		return 0;
	pid = pPage->m_grPageID;
	x = label_p->m_rPosition.left;
	y = label_p->m_rPosition.top;
	w = label_p->m_rPosition.right -  label_p->m_rPosition.left;
	h = label_p->m_rPosition.bottom -  label_p->m_rPosition.top;

	id 	= CreateWindow(LABEL_MINIGUI,"",WS_VISIBLE | WS_CHILD ,0,x,y,w,h,pPage->m_grPageID,0);


	label_p->m_grLabelID = id;
	info = (WinInfo*)malloc(sizeof(struct _WinInfo));
	memset((void*)info,0,sizeof(struct _WinInfo));
	info->id = id;
	info->type = LABEL_X;
	info->obj = (void*)label_p;
	PushInfo(info);

	ShowWindows(id);
	if(debug_flag)
		printf("Create Label wid : %d !\n",id);
	return id;	
}
// if page_p != 0,please offset it's coordinate .
HWND CreateButton(Button* button_p,Page* page_p)
{
	int x,y,w,h;
	HWND  id;
	HWND pid = 0;
	WinInfo* info = 0;
	Page* pPage = 0;
	pPage = (Page*)button_p->m_pParentPage;
	if(!button_p || !pPage)
		return 0;
	pid = pPage->m_grPageID;
	x = button_p->m_rPosition.left;
	y = button_p->m_rPosition.top;
	w = button_p->m_rPosition.right -  button_p->m_rPosition.left;
	h = button_p->m_rPosition.bottom -  button_p->m_rPosition.top;

	id 	= CreateWindow(BUTTON_MINIGUI,"",WS_VISIBLE | WS_CHILD ,0,x,y,w,h,pPage->m_grPageID,0);


	button_p->m_grButtonID = id;
	info = (WinInfo*)malloc(sizeof(struct _WinInfo));
	memset((void*)info,0,sizeof(struct _WinInfo));
	info->id = id;
	info->type = BUTTON_X;
	info->obj = (void*)button_p;
	PushInfo(info);

	ShowWindows(id);
	if(debug_flag)
		printf("Create Button wid : %d !\n",id);
	return id;	
}


HWND CreateBorder(Border* border_p,Page* page_p)
{
	int x,y,w,h;
	HWND  id;
	HWND pid = 0;
	WinInfo* info = 0;
	Page* pPage = 0;
	pPage = (Page*)border_p->m_pParentPage;
	if(!border_p)
		return 0;
	pid = pPage->m_grPageID;
	x = border_p->m_rPosition.left;
	y = border_p->m_rPosition.top;
	w = border_p->m_rPosition.right -  border_p->m_rPosition.left;
	h = border_p->m_rPosition.bottom -  border_p->m_rPosition.top;

	id 	= CreateWindow(BORDER_MINIGUI,"this is a test program",WS_VISIBLE | WS_CHILD ,0,x,y,w,h,pPage->m_grPageID,0);

	border_p->m_grBorderID = id;
	info = (WinInfo*)malloc(sizeof(struct _WinInfo));
	memset((void*)info,0,sizeof(struct _WinInfo));
	info->id = id;
	info->type = BORDER_X;
	info->obj = (void*)border_p;
	PushInfo(info);

	ShowWindows(id);

	
	if(debug_flag)
		printf("Create Border wid : %d !\n",id);
	return id;
}
int list_add_widget(Page* page_p,eWidgetType type,void* widget_p)
{
	int i = 0;
	WidgetList prv;
	WidgetList p;
	WidgetList* address;
	int subpage_no =0;
	int* pos;
	
	if (page_p == NULL)
		return -1;

	address = &page_p->m_wlWidgetList;
	p = page_p->m_wlWidgetList;
	prv = p;

	while(p){
		i++;
		if (p->widget_type == SUBPAGE_X)
			subpage_no++;
		prv = p;
		address=&p->next ;
		p = p->next;
	}

	p = (WidgetList)malloc(sizeof(struct _WIDGET_LIST));
	if( 0 == p)
		return i;

	memset(p,0,sizeof(struct _WIDGET_LIST));
	
	p->widget_type = type;

	// 2003 6 12
	if (type == SUBPAGE_X)
	{	
		pos = widget_p;
		subpage_no = *pos;
		p->subpage_pos = subpage_no;
	}
	else
	{	
		p->subpage_pos = -1;
		p->widget_pointer = widget_p;
	}
	
	*address=p;

	i++;
	if (type == SUBPAGE_X)
		return ++subpage_no;
	else
		return i;
}
void FreeResource()
{
	int i;
	Page* page;
	for(i=0;i<g_list_number;i++)
	{
		page = &g_list[i];
		if(page!=NULL)
			page_free_resource(page);
	}
	if(g_page)	
		free (g_page);		
	AssoilRes();
	Misc_destroy();
/*	FreeInfo();		// windows list.
	if(ServiceTimer_TtysRecv>0)
	{
		ServiceTimer_TtysRecv = 0;
	}

	if(wid_fCommRecv > 0)
		GrDestroyWindow(wid_fCommRecv);
	if(wid_fGlobal > 0)
		GrDestroyWindow(wid_fGlobal);

	Serial_Stop_Ttys2();
	Socket_end();

	if(gGQueue)
		DisposeQueue(gGQueue);

	Destroytheme();
*/
}


static int miniGUIWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	switch (message) {
	case MSG_CLOSE:
		DestroyMainWindow (hWnd);
		PostQuitMessage (hWnd);
		return 0;
	}
	return DefaultMainWinProc(hWnd, message, wParam, lParam);
}

static timerHandle = 0;
int GenTimerHandle()
{
	timerHandle ++;
	if(timerHandle >32)
		timerHandle = 1;
	return timerHandle;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -