Ejemplo n.º 1
0
Widget CreateMenubar(Widget parent)
{
    Widget
        cascade_w,
        menubar_w,
        menupane_w;

    /* create the menubar (row column) widget */
    menubar_w=XmCreateMenuBar(parent,"menubarw",NULL,0);         

    /* create the File pulldown menu */
    menupane_w=CreateMenu(menubar_w,"filemenu","File",0,NULL);
    CreateMenuItem(menupane_w,"quit","Quit",'Q',
            DoActionCb,"quit");

    /* create the Options pulldown menu */
    menupane_w=CreateMenu(menubar_w,"optionsmenu","Options",0,NULL);
    CreateMenuItem(menupane_w,"editc","Edit Config File",'E',
            DoActionCb,"editc");

    /* create the Help pulldown menu */
    menupane_w=CreateMenu(menubar_w,"helpmenu","Help",0,&cascade_w);
    XtVaSetValues(menubar_w,
        XmNmenuHelpWidget,cascade_w,
        NULL);
    CreateMenuItem(menupane_w,"about","About ...",'A',
            DoActionCb,"about");

    return (menubar_w);
}
Ejemplo n.º 2
0
GtkWidget *CreateMenuShutDown(GtkWidget *MenuItem)
{
	GtkWidget *Menu;
	GtkWidget *Restart, *ShutDown, *LogOut;
	Menu = gtk_menu_new();
	ShutDown = CreateMenuItem(Menu, "关机");
	LogOut = CreateMenuItem(Menu, "注销");
	Restart = CreateMenuItem(Menu, "重启");
	gtk_signal_connect(GTK_OBJECT(ShutDown), "activate", GTK_SIGNAL_FUNC(shutdown), NULL);
	gtk_signal_connect(GTK_OBJECT(LogOut), "activate", GTK_SIGNAL_FUNC(logout), NULL);
	gtk_signal_connect(GTK_OBJECT(Restart), "activate", GTK_SIGNAL_FUNC(restart), NULL);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(MenuItem), Menu);
	gtk_widget_show(Menu);
}
Ejemplo n.º 3
0
/** Create a window layer submenu. */
void CreateWindowLayerMenu(Menu *menu, ClientNode *np)
{

   Menu *submenu;
   MenuItem *item;

   item = CreateMenuItem(MENU_ITEM_SUBMENU);
   item->name = CopyString(_("Layer"));
   item->action.type = MA_NONE;
   item->next = menu->items;
   menu->items = item;

   submenu = CreateMenu();
   item->submenu = submenu;

   if(np->state.layer == LAYER_ABOVE) {
      AddWindowMenuItem(submenu, _("[Above]"), MA_LAYER, np, LAYER_ABOVE);
   } else {
      AddWindowMenuItem(submenu, _("Above"), MA_LAYER, np, LAYER_ABOVE);
   }
   if(np->state.layer == LAYER_NORMAL) {
      AddWindowMenuItem(submenu, _("[Normal]"), MA_LAYER, np, LAYER_NORMAL);
   } else {
      AddWindowMenuItem(submenu, _("Normal"), MA_LAYER, np, LAYER_NORMAL);
   }
   if(np->state.layer == LAYER_BELOW) {
      AddWindowMenuItem(submenu, _("[Below]"), MA_LAYER, np, LAYER_BELOW);
   } else {
      AddWindowMenuItem(submenu, _("Below"), MA_LAYER, np, LAYER_BELOW);
   }

}
Ejemplo n.º 4
0
BOOL ContextMenu::BuildCommand(TCHAR* pOpToken, BOOL Separator, MenuItem* pRootMenu, const String& strNewText, OpMenuParam* pParam)
{
	MenuItem* pNewItem;

	// If caller hasn't specified a root menu use the root of the whole thing...
	if (pRootMenu == NULL)
		pRootMenu = pRootItem;

	// Create a new kernel menu item...
	pNewItem = CreateMenuItem(pOpToken, pRootMenu->GetMenuId(), Separator);

	// If that worked, add it to the root menu. Else flag failure.
	if (pNewItem)
	{
		pLastItem = pNewItem;

		if (!strNewText.IsEmpty())
			pNewItem->SetMenuText(strNewText);

		if (pParam)
			pNewItem->SetMenuParam(pParam);

		pRootMenu->AddMenuItem(pNewItem);

		return TRUE;
	}
	else
		return FALSE;
}
Ejemplo n.º 5
0
Archivo: parse.c Proyecto: Nehamkin/jwm
/** Insert a new menu item into a menu. */
MenuItem *InsertMenuItem(MenuItem *last)
{
   MenuItem *item = CreateMenuItem(MENU_ITEM_NORMAL);
   if(last) {
      last->next = item;
   }
   return item;
}
Ejemplo n.º 6
0
//创建子菜单项
void CreateMenuTask(GtkWidget *MenuItem)
{
    GtkWidget *Menu;
   	Menu = gtk_menu_new();
   	GtkWidget *Exit;
   	Exit = CreateMenuItem(Menu,"关机选项");
    gtk_signal_connect(GTK_OBJECT(Exit),"activate",G_CALLBACK(gtk_main_quit),NULL);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(MenuItem),Menu);//菜单栏关联根菜单项
}
Ejemplo n.º 7
0
GtkWidget *CreateMenuHelp(GtkWidget *MenuItem)
{
	GtkWidget *Menu;
	GtkWidget *AboutGtk;
	Menu = gtk_menu_new();
	AboutGtk = CreateMenuItem(Menu, "关于该利器");
	gtk_signal_connect(GTK_OBJECT(AboutGtk), "activate", GTK_SIGNAL_FUNC(aboutSysMo), NULL);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(MenuItem), Menu);
	gtk_widget_show(Menu);
}
Ejemplo n.º 8
0
GtkWidget *CreateMenuFile(GtkWidget *MenuItem)
{
	GtkWidget *Menu;
	GtkWidget *Exit;
	Menu = gtk_menu_new();
	Exit = CreateMenuItem(Menu, "退出");
	gtk_signal_connect(GTK_OBJECT(Exit), "activate", GTK_SIGNAL_FUNC(delete_event), NULL);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(MenuItem), Menu);
	gtk_widget_show(Menu);
}
Ejemplo n.º 9
0
/*****************************************************************************
 * Refresh the menu.
 *****************************************************************************/
void RefreshMenu( intf_thread_t *p_intf, vector<MenuItemExt*> *p_menu_list,
                  HMENU hMenu , int i_count, char **ppsz_varnames,
                  vlc_object_t **pi_objects, int i_start_id )
{
    vlc_object_t *p_object;
    bool b_section_empty = false;
    int i;

    /* Initializations */
    int i_item_id = i_start_id;

    for( i = 0; i < i_count; i++ )
    {
        if( !ppsz_varnames[i] )
        {
            if( b_section_empty )
            {
                AppendMenu( hMenu, MF_GRAYED | MF_STRING,
                            MenuDummy_Event + i, _T("Empty") );
            }

            AppendMenu( hMenu, MF_SEPARATOR, 0, _T("") );
            b_section_empty = true;
            continue;
        }

        if( !pi_objects[i] )
        {
            AppendMenu( hMenu, MF_GRAYED | MF_STRING,
                        MenuDummy_Event, _FROMMB(ppsz_varnames[i]) );

            b_section_empty = false;
            continue;
        }

        p_object = pi_objects[i];
        if( p_object == NULL ) continue;

        b_section_empty = false;
        CreateMenuItem( p_intf, p_menu_list, hMenu, ppsz_varnames[i],
                        p_object, &i_item_id );
        vlc_object_release( p_object );
    }

    /* Special case for empty menus */
    if( wce_GetMenuItemCount(hMenu) == 0 || b_section_empty )
    {
        AppendMenu( hMenu, MF_GRAYED | MF_STRING,
                    MenuDummy_Event + i, _T("Empty") );
    }
}
Ejemplo n.º 10
0
/** Add an item to the current window menu. */
void AddWindowMenuItem(Menu *menu, const char *name, MenuActionType type,
                       ClientNode *np, int value)
{

   MenuItem *item;

   item = CreateMenuItem(name ? MENU_ITEM_NORMAL : MENU_ITEM_SEPARATOR);
   item->name = CopyString(name);
   item->action.type = type;
   item->action.context = np;
   item->action.value = value;
   item->next = menu->items;
   menu->items = item;

}
Ejemplo n.º 11
0
 virtual BOOL CreateChildren(pugi::xml_node xmlNode)
 {
     pugi::xml_node xmlItem = xmlNode.first_child();
     while(xmlItem)
     {
         SWindow *pMenuItem = CreateMenuItem(xmlItem.name());
         if(pMenuItem)
         {
             InsertChild(pMenuItem);
             pMenuItem->InitFromXml(xmlItem);
             pMenuItem->SetAttribute(L"pos",L"0,[0",TRUE);
         }
         xmlItem = xmlItem.next_sibling();
     }
     return TRUE;
 }
Ejemplo n.º 12
0
/*主函数*/
int main(int argc,char *argv[]){ 

 gint i; 

 int v,v0; 

 int timer; 

 GtkWidget *label2,*label; 

 GtkWidget *label0[5]; 

 GtkWidget *text; 

 gpointer date,data; 

 gdouble value1,value2; 

 gpointer gdata; 

 GtkWidget *label3; 

 GtkWidget *button1;  
 
 GtkWidget *vscrollbar,*hscrollbar;//定义滚动条 

 GtkWidget *MenuBar;//定义菜单栏 

 GtkWidget *MenuItemFile,*MenuItemShutDown,*MenuItemHelp; 
 
 gtk_set_locale (); 

 gtk_init(&argc,&argv);//在任何构件生成之前完成 

 memset (pfuser, 0 ,sizeof (pfuser)); 

 

 window=gtk_window_new(GTK_WINDOW_TOPLEVEL);//创建主窗口 

 gtk_window_set_title(GTK_WINDOW(window),"---------linux任务管理器-----------");//设置窗口标题 

 gtk_widget_set_usize(window, 600, 500);//设置窗口大小  

 gtk_window_set_resizable (GTK_WINDOW (window), TRUE);// 窗口大小可改变(TRUE) 

 gtk_container_set_border_width(GTK_CONTAINER(window),5);//设置窗口边框宽度 

 gtk_widget_show(window); 

 

 table=gtk_table_new(12,11,TRUE);//创建表格12行*10列 

 gtk_widget_show(table); 

 gtk_container_add(GTK_CONTAINER(window),table);//将table装进窗口  

 

 notebook=gtk_notebook_new();//创建notebook 

 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook),GTK_POS_TOP);//设置notebook的格式 

 gtk_table_attach_defaults (GTK_TABLE (table), notebook, 0, 11, 1, 11);//将notebook加入表格中 

 gtk_widget_show(notebook); 

 /*创建notebook的每一页*/ 

 for(i=0;i<5;i++){    

  label0[i]=gtk_label_new(title[i]);//notebook页面标题            

  frame[i]=gtk_frame_new(NULL);//页面框架 

  gtk_container_set_border_width (GTK_CONTAINER (frame[i]), 10);//框架与边缘的距离 

  gtk_frame_set_shadow_type (GTK_FRAME (frame[i]),GTK_SHADOW_ETCHED_OUT);//框架的阴影模式 

  gtk_widget_set_size_request(frame[i],450,450);//框架大小 

  gtk_widget_show(frame[i]); 

  gtk_widget_show (label0[i]); 

  gtk_notebook_append_page(GTK_NOTEBOOK(notebook),frame[i],label0[i]);//创建notebook的第i页   

  table1[i]=gtk_table_new(12,11,TRUE);//创建表格12行*11列 

  gtk_widget_show(table1[i]); 

  gtk_container_add(GTK_CONTAINER(frame[i]),table1[i]);//将表格tbale1放入框架 
 } 
 
 MenuBar=gtk_menu_bar_new();//创建菜单栏 

 gtk_table_attach_defaults(GTK_TABLE(table),MenuBar,0,11,0,1);//将菜单栏加入表格 

 MenuItemFile=CreateMenuItem(MenuBar,"文件");//增加菜单项 

  MenuItemHelp=CreateMenuItem(MenuBar,"帮助");//增加菜单项 

  gtk_widget_show(MenuBar); 

 

    process_label=gtk_label_new("");//创建显示进程数的标签 

    gtk_widget_show(process_label); 
    
//    timer=gtk_timeout_add(1000,(GtkFunction)process_num,data);//加一个定时器(timer),每隔1秒调用一次(GtkFunction)process_num函数 

    gtk_table_attach_defaults(GTK_TABLE(table),process_label,0,2,11,12);//在状态栏中显示进程总数 

     cpu_rate_label=gtk_label_new(" ");//创建显示cpu占用率的标签 

    gtk_widget_show(cpu_rate_label); 

 gtk_table_attach_defaults(GTK_TABLE(table),cpu_rate_label,2,5,11,12);//在状态栏中显示cpu占用率 
    
 cpu_bar=gtk_progress_bar_new();//创建CPU进度条 

 gtk_widget_show(cpu_bar); 
 notebook_cpu_init(); 
 
 gtk_signal_connect(GTK_OBJECT(window),"delete_event",GTK_SIGNAL_FUNC(delete_event),NULL); 

  gtk_main(); 
} 
Ejemplo n.º 13
0
/** Show the menu associated with a task list item. */
void ShowClientList(TaskBarType *bar, TaskEntry *tp)
{
   Menu *menu;
   MenuItem *item;
   ClientEntry *cp;

   const ScreenType *sp;
   int x, y;
   Window w;

   if(settings.groupTasks) {

      menu = Allocate(sizeof(Menu));
      menu->itemHeight = 0;
      menu->items = NULL;
      menu->label = NULL;

      item = CreateMenuItem(MENU_ITEM_NORMAL);
      item->name = CopyString(_("Close"));
      item->action.type = MA_CLOSE | MA_GROUP_MASK;
      item->action.context = tp;
      item->next = menu->items;
      menu->items = item;

      item = CreateMenuItem(MENU_ITEM_NORMAL);
      item->name = CopyString(_("Minimize"));
      item->action.type = MA_MINIMIZE | MA_GROUP_MASK;
      item->action.context = tp;
      item->next = menu->items;
      menu->items = item;

      item = CreateMenuItem(MENU_ITEM_NORMAL);
      item->name = CopyString(_("Restore"));
      item->action.type = MA_RESTORE | MA_GROUP_MASK;
      item->action.context = tp;
      item->next = menu->items;
      menu->items = item;

      item = CreateMenuItem(MENU_ITEM_SUBMENU);
      item->name = CopyString(_("Send To"));
      item->action.type = MA_SENDTO_MENU | MA_GROUP_MASK;
      item->action.context = tp;
      item->next = menu->items;
      menu->items = item;

      /* Load the separator and group actions. */
      item = CreateMenuItem(MENU_ITEM_SEPARATOR);
      item->next = menu->items;
      menu->items = item;

      /* Load the clients into the menu. */
      for(cp = tp->clients; cp; cp = cp->next) {
         if(!ShouldFocus(cp->client, 0)) {
            continue;
         }
         item = CreateMenuItem(MENU_ITEM_NORMAL);
         if(cp->client->state.status & STAT_MINIMIZED) {
            size_t len = 0;
            if(cp->client->name) {
               len = strlen(cp->client->name);
            }
            item->name = Allocate(len + 3);
            item->name[0] = '[';
            memcpy(&item->name[1], cp->client->name, len);
            item->name[len + 1] = ']';
            item->name[len + 2] = 0;
         } else {
            item->name = CopyString(cp->client->name);
         }
         item->icon = cp->client->icon ? cp->client->icon : GetDefaultIcon();
         item->action.type = MA_EXECUTE;
         item->action.context = cp->client;
         item->next = menu->items;
         menu->items = item;
      }
   } else {
      /* Not grouping clients. */
      menu = CreateWindowMenu(tp->clients->client);
   }

   /* Initialize and position the menu. */
   InitializeMenu(menu);
   sp = GetCurrentScreen(bar->cp->screenx, bar->cp->screeny);
   GetMousePosition(&x, &y, &w);
   if(bar->layout == LAYOUT_HORIZONTAL) {
      if(bar->cp->screeny + bar->cp->height / 2 < sp->y + sp->height / 2) {
         /* Bottom of the screen: menus go up. */
         y = bar->cp->screeny + bar->cp->height;
      } else {
         /* Top of the screen: menus go down. */
         y = bar->cp->screeny - menu->height;
      }
      x -= menu->width / 2;
      x = Max(x, sp->x);
   } else {
      if(bar->cp->screenx + bar->cp->width / 2 < sp->x + sp->width / 2) {
         /* Left side: menus go right. */
         x = bar->cp->screenx + bar->cp->width;
      } else {
         /* Right side: menus go left. */
         x = bar->cp->screenx - menu->width;
      }
      y -= menu->height / 2;
      y = Max(y, sp->y);
   }

   ShowMenu(menu, RunTaskBarCommand, x, y, 0);

   DestroyMenu(menu);

}
Ejemplo n.º 14
0
Uint32 cUIMenu::Add( const String& Text, cSubTexture * Icon ) {
	return Add( CreateMenuItem( Text, Icon ) );
}
Ejemplo n.º 15
0
//---------------------主函数--------------------
int main(int argc, char *argv[])
{
	int i;
	int timer;
	gpointer data, date;

	gtk_set_locale ();//初始化运行环境
	gtk_init(&argc,&argv);

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);//创建主窗口
	gtk_window_set_title(GTK_WINDOW(window),"查看进程使用内存地址的利器");//设置窗口标题
	gtk_widget_set_usize(window, 600, 500);//设置窗口大小 
	gtk_window_set_resizable (GTK_WINDOW (window), TRUE);// 窗口大小可改变(TRUE)
	gtk_container_set_border_width(GTK_CONTAINER(window),5);//设置窗口边框宽度
	gtk_widget_show(window);

	table = gtk_table_new(12,11,TRUE);//创建表格12行*11列
	gtk_widget_show(table);
	gtk_container_add(GTK_CONTAINER(window),table);//将table装进窗口 

	notebook = gtk_notebook_new();
	gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook),GTK_POS_TOP);//设置notebook的格式
	gtk_table_attach_defaults (GTK_TABLE (table), notebook, 0, 11, 1, 11);//将notebook加入表格中
	gtk_widget_show(notebook);
	for(i = 0; i < 5; i++)
	{
		label0[i] = gtk_label_new(title[i]);
		frame[i] = gtk_frame_new(NULL);
		gtk_container_set_border_width(GTK_CONTAINER(frame[i]), 10);
		gtk_frame_set_shadow_type(GTK_FRAME(frame[i]), GTK_SHADOW_ETCHED_OUT);
		gtk_widget_set_size_request(frame[i], 450, 450);
		gtk_widget_show(frame[i]);
		gtk_widget_show(label0[i]);
		gtk_notebook_append_page(GTK_NOTEBOOK(notebook), frame[i], label0[i]);
		table1[i] = gtk_table_new(12, 11, TRUE);
		gtk_widget_show(table1[i]);
		gtk_container_add(GTK_CONTAINER(frame[i]), table1[i]);
	}

	label = gtk_label_new("Select Memory Address By PID:");
	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 5, 0, 1);
	gtk_widget_show(label);

	entry = gtk_entry_new();
	gtk_table_attach_defaults(GTK_TABLE(table), entry, 6, 8, 0, 1);
	gtk_widget_show(entry);

	button = gtk_button_new_with_label(" SELECT ");
	gtk_widget_set_size_request(button, 10, 10);
	gtk_table_attach_defaults(GTK_TABLE(table), button, 9, 11, 0, 1);
	g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(on_clicked), NULL);
	gtk_widget_show(button);

	time_label = gtk_label_new("");
	timer = gtk_timeout_add(1000, (GtkFunction)sys_time, data);
	gtk_table_attach_defaults(GTK_TABLE(table), time_label, 7, 11, 1, 2);
	gtk_widget_show(time_label);				
	
	uptime_label = gtk_label_new("");
	timer = gtk_timeout_add(1000, (GtkFunction)uptime, data);
//	gtk_table_attach_defaults(GTK_TABLE(table), uptime_label, 7, 11, 0, 2);	
	gtk_widget_show(uptime_label);
	
	MenuBar = gtk_menu_bar_new();
	gtk_table_attach_defaults(GTK_TABLE(table), MenuBar, 0, 11, 0, 1);
	MenuItemFile = CreateMenuItem(MenuBar, "文件");
	CreateMenuFile(MenuItemFile);		
	MenuItemShutDown = CreateMenuItem(MenuBar, "关机选项");
	CreateMenuShutDown(MenuItemShutDown);
	MenuItemHelp = CreateMenuItem(MenuBar, "帮助");
	CreateMenuHelp(MenuItemHelp);
	gtk_widget_show(MenuBar);

	process_label = gtk_label_new("");
	timer = gtk_timeout_add(1000, (GtkFunction)process_num, data);
	gtk_table_attach_defaults(GTK_TABLE(table), process_label, 0, 2, 11, 12);
	gtk_widget_show(process_label);

	cpu_rate_label = gtk_label_new("");
	timer = gtk_timeout_add(1000, (GtkFunction)cpu_rate_ava, data);
	gtk_table_attach_defaults(GTK_TABLE(table), cpu_rate_label, 2, 5, 11, 12);
	gtk_widget_show(cpu_rate_label);

	mem_rate_label = gtk_label_new("");
	timer = gtk_timeout_add(1000, (GtkFunction)mem_rate_ava, data);
	gtk_table_attach_defaults(GTK_TABLE(table), mem_rate_label, 5, 8, 11, 12);
	gtk_widget_show(mem_rate_label);

	swap_rate_label = gtk_label_new("");
	timer = gtk_timeout_add(1000, (GtkFunction)swap_rate_ava, data);
	gtk_table_attach_defaults(GTK_TABLE(table), swap_rate_label, 8, 10, 11, 12);
	gtk_widget_show(swap_rate_label);

	cpu_bar = gtk_progress_bar_new();
	mem_bar = gtk_progress_bar_new();
	swap_bar = gtk_progress_bar_new();
	gtk_widget_show(cpu_bar);
	gtk_widget_show(mem_bar);
	gtk_widget_show(swap_bar);

	notebook_cpu_init();
	notebook_mem_init();
	notebook_pro_init();
//	notebook_vmem_init();

	v_label = gtk_label_new("");
	r_label = gtk_label_new("");

	gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(delete_event), NULL);
 
	gtk_main();
	return 0;
}
Ejemplo n.º 16
0
HMENUITEM CreateAndAppendMenuItemClassic(HPOPUP parent, UINT style, LPVOID param)
{
	HMENUITEM item = CreateMenuItem(parent, style, param);
	AppendMenuItemClassic(parent, item);
	return item;
}
Ejemplo n.º 17
0
void cUIMenu::Insert( const String& Text, cSubTexture * Icon, const Uint32& Index ) {
	Insert( CreateMenuItem( Text, Icon ), Index );
}
Ejemplo n.º 18
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int wmId, wmEvent;
    PAINTSTRUCT ps;
    HDC hdc;

    RECT rcClient;                       // The parent window's client area.
    static HMENU hMainMenu, hFileMenu;
    static HWND hSearchButton;
    int i;

    OPENFILENAME ofn;
    TCHAR szFileName[256] = "";

    static struct {
        TCHAR *name;
        int width;
    } columns[] = {
        { TEXT("Номер телефона:"), 100},
        { TEXT("Фамилия:"), 100},
        { TEXT("Имя:"), 100},
        { TEXT("Отчество:"), 100},
        { TEXT("Улица:"), 150},
        { TEXT("Дом:"), 100},
        { TEXT("Корпус:"), 100},
        { TEXT("Квартира:"), 100}
    };
    const int ColumnsCount = _countof(columns);

    switch (message)
    {
    case WM_CREATE:
        LoadDatabaseDLL();
        hMainMenu=CreateMenu();
        hFileMenu=CreatePopupMenu();
        i=0;
        CreateMenuItem(hFileMenu,"&Load database",i++,ID_BUTTONLOADDB,NULL,FALSE,MFT_STRING);
        CreateMenuItem(hFileMenu,"&Show database",i++,ID_BUTTONSHOWDB,NULL,FALSE,MFT_STRING);
        CreateMenuItem(hFileMenu,"&Exit",i++,IDM_EXIT,NULL,FALSE,MFT_STRING);
        i=0;
        CreateMenuItem(hMainMenu,"&File",i++,0,hFileMenu,FALSE,MFT_STRING);
        SetMenu(hWnd,hMainMenu);
        DrawMenuBar(hWnd);

        GetClientRect (hWnd, &rcClient);
        hListView = CreateWindowEx(
                        WS_EX_STATICEDGE,
                        WC_LISTVIEW,
                        NULL,
                        WS_CHILD|WS_VISIBLE|LVS_REPORT|LVS_EDITLABELS,
                        0, 0,
                        rcClient.right, rcClient.bottom-100,
                        hWnd, NULL, hInst, NULL);
        ListView_SetExtendedListViewStyle(hListView,LVS_EX_FULLROWSELECT);
        //adding columns
        for (int i=0; i<ColumnsCount; i++)
        {
            AddColumnToListView(hListView, columns[i].name, i, columns[i].width);
        }

        hPhoneLabel = CreateWindowEx( WS_EX_TRANSPARENT, "STATIC", "", WS_CHILD | WS_VISIBLE | SS_LEFT | WS_SYSMENU , 5, 400, 65, 25, hWnd, hMainMenu, hInst, NULL);
        SendMessage(hPhoneLabel, WM_SETTEXT, NULL, (LPARAM) "Телефон:");
        hLastNameLabel = CreateWindowEx( WS_EX_TRANSPARENT, "STATIC", "", WS_CHILD | WS_VISIBLE | SS_LEFT | WS_SYSMENU , 90, 400, 100, 25, hWnd, hMainMenu, hInst, NULL);
        SendMessage(hLastNameLabel, WM_SETTEXT, NULL, (LPARAM) "Фамилия:");
        hNameLabel = CreateWindowEx( WS_EX_TRANSPARENT, "STATIC", "", WS_CHILD | WS_VISIBLE | SS_LEFT | WS_SYSMENU , 190, 400, 100, 25, hWnd, hMainMenu, hInst, NULL);
        SendMessage(hNameLabel, WM_SETTEXT, NULL, (LPARAM) "Имя:");
        hPatronymLabel = CreateWindowEx( WS_EX_TRANSPARENT, "STATIC", "", WS_CHILD | WS_VISIBLE | SS_LEFT | WS_SYSMENU , 290, 400, 100, 25, hWnd, hMainMenu, hInst, NULL);
        SendMessage(hPatronymLabel, WM_SETTEXT, NULL, (LPARAM) "Отчество:");
        hStreetLabel = CreateWindowEx( WS_EX_TRANSPARENT, "STATIC", "", WS_CHILD | WS_VISIBLE | SS_LEFT | WS_SYSMENU , 390, 400, 150, 25, hWnd, hMainMenu, hInst, NULL);
        SendMessage(hStreetLabel, WM_SETTEXT, NULL, (LPARAM) "Улица");
        hHouseLabel = CreateWindowEx( WS_EX_TRANSPARENT, "STATIC", "", WS_CHILD | WS_VISIBLE | SS_LEFT | WS_SYSMENU , 540, 400, 50, 25, hWnd, hMainMenu, hInst, NULL);
        SendMessage(hHouseLabel, WM_SETTEXT, NULL, (LPARAM) "Дом");
        hHousingLabel = CreateWindowEx( WS_EX_TRANSPARENT, "STATIC", "", WS_CHILD | WS_VISIBLE | SS_LEFT | WS_SYSMENU , 590, 400, 60, 25, hWnd, hMainMenu, hInst, NULL);
        SendMessage(hHousingLabel, WM_SETTEXT, NULL, (LPARAM)"Корпус:");
        hApartmentLabel = CreateWindowEx( WS_EX_TRANSPARENT, "STATIC", "", WS_CHILD | WS_VISIBLE | SS_LEFT | WS_SYSMENU , 650, 400, 30, 25, hWnd, hMainMenu, hInst, NULL);
        SendMessage(hApartmentLabel, WM_SETTEXT, NULL, (LPARAM) "кв:");

        hPhoneEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_LEFT,	3, 425, 83, 25,	hWnd, (HMENU)(101),	hInst, NULL);
        hLastNameEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_LEFT,	90, 425, 98, 25,	hWnd, (HMENU)(101),	hInst, NULL);
        hNameEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_LEFT,	190, 425, 98, 25,	hWnd, (HMENU)(101),	hInst, NULL);
        hPatronymEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_LEFT,	290, 425, 98, 25,	hWnd, (HMENU)(101),	hInst, NULL);
        hStreetEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_LEFT,	390, 425, 148, 25,	hWnd, (HMENU)(101),	hInst, NULL);
        hHouseEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_LEFT,	540, 425, 98, 25,	hWnd, (HMENU)(101),	hInst, NULL);
        hHousingEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_LEFT,	590, 425, 58, 25,	hWnd, (HMENU)(101),	hInst, NULL);
        hApartmentEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_LEFT,	650, 425, 28, 25,	hWnd, (HMENU)(101),	hInst, NULL);

        hSearchButton = CreateWindowEx(
                            WS_EX_STATICEDGE,
                            WC_BUTTON,
                            NULL,
                            WS_CHILD|WS_VISIBLE|LVS_REPORT|LVS_EDITLABELS,
                            690, 425,
                            50, 25,
                            hWnd, NULL, hInst, NULL);
        SendMessage(hSearchButton, WM_SETTEXT, NULL, (LPARAM) "Поиск");

        ShowWindow(hWnd, NULL);
        UpdateWindow(hWnd);
        break;
    case WM_COMMAND:
        wmId    = LOWORD(wParam);
        wmEvent = HIWORD(wParam);
        // Parse the menu selections:
        switch (wmId)
        {
        case BN_CLICKED:
            if ((HWND)lParam == hSearchButton)
                SearchDB(hWnd, hListView);
            break;
        case ID_BUTTONLOADDB:
            ZeroMemory(&ofn, sizeof(ofn));
            ofn.lStructSize = sizeof(ofn);
            ofn.hwndOwner = hWnd;
            ofn.lpstrFilter = "Text files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
            ofn.lpstrFile = szFileName;
            ofn.nMaxFile = MAX_PATH;
            ofn.lpstrTitle = "Open File";
            ofn.Flags = OFN_PATHMUSTEXIST;
            ofn.lpstrDefExt = "txt";

            if(GetOpenFileName(&ofn))
            {
                LoadDB(szFileName,hWnd);
            }
            InvalidateRect(hWnd,NULL,TRUE);
            UpdateWindow(hWnd);

            break;
        case ID_BUTTONSHOWDB:
            ShowDB(hWnd);
            break;
        case IDM_ABOUT:
            DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
            break;
        case IDM_EXIT:
            DestroyWindow(hWnd);
            break;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        break;
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);
        // TODO: Add any drawing code here...
        EndPaint(hWnd, &ps);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
Ejemplo n.º 19
0
int main(int argc, char *argv[])
{
	GtkWidget *window;
	GtkWidget *table1;
	GtkWidget *menuBar;
	GtkWidget *noteBook;
	GtkWidget *MenuItemTask;
	const char *title[3] = {"总体信息","进程信息","系统信息"};
	GtkWidget *label[Nsize];//页面标题
	GtkWidget *frame[Nsize];//页面框架
	gtk_init(&argc, &argv);//初始化命令行参数 虽不使用但是必需
	
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(window),"任务管理器");
	gtk_widget_set_usize(window, 600, 600); 
	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
	gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
	gtk_container_set_border_width(GTK_CONTAINER(window),5);
	
	table1 = gtk_table_new(11,11,TRUE);
	gtk_container_add(GTK_CONTAINER(window),table1);
	
	menuBar = gtk_menu_bar_new();
	gtk_table_attach_defaults(GTK_TABLE(table1), menuBar,0,11,0,1);
	MenuItemTask = CreateMenuItem(menuBar, "进程");
  	CreateMenuTask(MenuItemTask);
  	
   	noteBook = gtk_notebook_new();
	gtk_notebook_set_tab_pos(GTK_NOTEBOOK(noteBook),GTK_POS_TOP);//设置notebook的格式
	gtk_table_attach_defaults(GTK_TABLE(table1), noteBook, 0, 11, 1, 10);
	gint i;
	for(i = 0; i < Nsize; i++)
	{
		label[i] = gtk_label_new(title[i]);
		frame[i] = gtk_frame_new(NULL);
		gtk_container_set_border_width(GTK_CONTAINER(frame[i]), 5);
		gtk_widget_set_size_request(frame[i],450,450);
		gtk_notebook_append_page(GTK_NOTEBOOK(noteBook),frame[i],label[i]);
		table2[i] = gtk_table_new(12,12,TRUE);
		gtk_container_add(GTK_CONTAINER(frame[i]),table2[i]);
	}
	
	time_label = gtk_label_new("");
	 gtk_timeout_add(1000, (GtkFunction)get_time, NULL);
	gtk_table_attach_defaults(GTK_TABLE(table1), time_label, 8,10,1,2);
	
	cpu_label = gtk_label_new("");
	gtk_timeout_add(3000, (GtkFunction)get_cpu_rate, NULL);
	gtk_table_attach_defaults(GTK_TABLE(table1), cpu_label, 1,3,10,11);
	
	mem_label = gtk_label_new("");
	gtk_timeout_add(3000, (GtkFunction)get_mem_rate, NULL);
	gtk_table_attach_defaults(GTK_TABLE(table1), mem_label, 8,10,10,11);
	
	process_num_label = gtk_label_new("");
	gtk_timeout_add(1000, (GtkFunction)get_process_num, NULL);
	gtk_table_attach_defaults(GTK_TABLE(table1), process_num_label, 4,7,10,11);
	
	pro_init();
	gtk_timeout_add(3000, (GtkFunction)pro_fill, NULL);
	
	info_init();
	
	drawlines_init();
	gtk_timeout_add(1000, (GtkFunction)lines_refresh, NULL);
	
	g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(gtk_main_quit), NULL);//可关闭
	gtk_widget_show_all(window);
	gtk_main();//主事件循环
	return 0;
}
Ejemplo n.º 20
0
HMENUITEM CreateAndInsertMenuItemClassic(HPOPUP parent, UINT style, LPVOID param, int index)
{
	HMENUITEM item = CreateMenuItem(parent, style, param);
	InsertMenuItemClassic(parent, item, index);
	return item;
}