永发信息网

编写空间后方交会程序

答案:1  悬赏:10  手机版
解决时间 2021-01-19 13:32
  • 提问者网友:临风不自傲
  • 2021-01-19 07:32
编写空间后方交会程序
最佳答案
  • 五星知识达人网友:酒安江南
  • 2021-01-19 08:14
#include
#include "resource.h"

#pragma once
#include
#pragma comment(lib,"comctl32.lib")

HWND m_CTab[2];

LRESULT CALLBACK Tab1_DlgProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK Tab2_DlgProc(HWND, UINT, WPARAM, LPARAM);

BOOL CreateTabDialog(HWND hParent);

void UpdateTab(HWND hParent);

HINSTANCE hInst;

LRESULT CALLBACK DlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
hInst = hInstance;
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC) DlgProc);
return 0;
}

LRESULT CALLBACK DlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{

LPNMHDR etat = (LPNMHDR) lParam;

switch(Msg)
{
case WM_INITDIALOG:

InitCommonControls();

CreateTabDialog(hWnd);
break;

case WM_COMMAND:
switch(LOWORd(wParam))
{
case IDC_QUITTER:
EndDialog(hWnd,IDC_QUITTER);
break;

case IDC_APROPOS:
MessageBox(hWnd,"123","A Propos",MB_ICONINFORMATION);
break;
}
break;

case WM_NOTIFY:
switch(etat->code)
{
case TCN_SELCHANGE:

UpdateTab(hWnd);
break;
}
break;

case WM_CLOSE:
EndDialog(hWnd,IDC_QUITTER);
break;

default:
return(FALSE);
}

return(TRUE);
}

BOOL CreateTabDialog(HWND hParent)
{

HWND hTabCtl = GetDlgItem(hParent, IDC_TABCTL);
TCITEM tci;

m_CTab[0] = CreateDialog(hInst, MAKEINTRESOURCE(IDD_TAB1), hParent, (DLGPROC) Tab1_DlgProc);
m_CTab[1] = CreateDialog(hInst, MAKEINTRESOURCE(IDD_TAB2), hParent, (DLGPROC) Tab2_DlgProc);

tci.mask = TCIF_TEXT;
tci.pszText = "Onglet 1";
SendMessage(hTabCtl, TCM_INSERTITEM, 0, (LPARAM) &tci);
tci.pszText = "Onglet 2";
SendMessage(hTabCtl, TCM_INSERTITEM, 1, (LPARAM) &tci);

RECT rcTabCtl;
GetWindowRect(hTabCtl, &rcTabCtl);
SendMessage(hTabCtl, TCM_ADJUSTRECT, FALSE, (LPARAM) &rcTabCtl);
MapWindowPoints(NULL, hParent, (LPPOINT) &rcTabCtl, 2);

for(int i = 0; i <= 1; i++)
{

RECT rcTab;
GetWindowRect(m_CTab[i], &rcTab);
int x = (rcTabCtl.left+rcTabCtl.right)/2 - (rcTab.right-rcTab.left)/2;
int y = (rcTabCtl.top+rcTabCtl.bottom)/2 - (rcTab.bottom-rcTab.top)/2;
SetWindowPos(m_CTab[i], NULL, x, y, 0, 0, SWP_NOZORDER|SWP_NOSIZE|SWP_NOREDRAW);
}

SendMessage(hTabCtl, TCM_SETCURSEL, 0, 0);
UpdateTab(hParent);

return true;
}

void UpdateTab(HWND hParent)
{

HWND hTabCtl = GetDlgItem(hParent, IDC_TABCTL);
int nSelected = SendMessage(hTabCtl, TCM_GETCURSEL, 0, 0);
for(int i = 0; i <= 1; i++)
ShowWindow(m_CTab[i], (i==nSelected) ? SW_SHOW : SW_HIDE);
}

//tab1

#include
#include "resource.h"

LRESULT CALLBACK Tab1_DlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_COMMAND:
switch(LOWORd(wParam))
{
case IDC_MESSAGE:
MessageBox(hDlg,"Juste un ptit message pour dire qu'on est sur l'onglet n?","Onglet 1", MB_ICONINFORMATION);
break;
}
break;
}

return 0;
}

//tab2
#include
#include "resource.h"

LRESULT CALLBACK Tab2_DlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_COMMAND:
switch(LOWORd(wParam))
{
case IDC_COUCOU:
MessageBox(hDlg,"Un ptit COUCOU pour dire que tout marche pour le mieux!","Onglet 2", MB_ICONINFORMATION);
break;
}
break;
}

return 0;
}

#define IDD_DIALOG1 101
#define IDD_DIALOG2 102
#define IDD_TAB1 102
#define IDD_TAB2 103
#define IDC_TAB1 1000
#define IDC_TABCTL 1000
#define IDC_CHECK1 1001
#define IDC_RADIO1 1002
#define IDC_MESSAGE 1003
#define IDC_COUCOU 1005
#define IDC_QUITTER 1006
#define IDC_APROPOS 1007

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1008
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯