2017-07-21 2 views
0

Ich habe den folgenden Code, die Linien auf ganze Form Unentschieden:erstellen d3d drawlines Funktion innerhalb Panel-Register bei Index 0

/* Create GridLines */ 
bool CreateGridLines() 
{ 
RECT rcTabControl; 

GetWindowRect(hwndTabControl, &rcTabControl); 
app_scale_x = (float)((rcTabControl.right - rcTabControl.left)/96.0); 
app_scale_y = (float)((rcTabControl.bottom - rcTabControl.top)/96.0); 

/* Get desktop DPI. 
HDC screen = GetDC(0); 
app_scale_x = (float)(GetDeviceCaps(screen, LOGPIXELSX)/96.0); 
app_scale_y = (float)(GetDeviceCaps(screen, LOGPIXELSX)/96.0); 
ReleaseDC(0, screen);*/ 

d3d_object = Direct3DCreate9(D3D_SDK_VERSION); 

/* Fill out the presentation parameters for the D3D device... windowed mode. */ 
D3DPRESENT_PARAMETERS present; 
fill_out_present(&present, hwnd); 


UINT AdapterToUse = D3DADAPTER_DEFAULT; 
D3DDEVTYPE DeviceType = D3DDEVTYPE_HAL; 

d3d_object->CreateDevice(AdapterToUse, DeviceType, hwnd, 
         D3DCREATE_FPU_PRESERVE | D3DCREATE_SOFTWARE_VERTEXPROCESSING, 
         &present, &d3d_device); 

if (!d3d_device) return false; 

return true; 
} 

Das Problem ist, wie ich diese Zeilen innerhalb Panel Index 0 ziehen kann? Ich erhalte diese Quellcode-Skript aus:

http://braid-game.com/news/wp-content/uploads/2009/01/proof.cpp 

I definiert und initialisierte Platte wie folgt aus:

HWND  hwndTabControl; 

    /* CreateTabControl */ 
HWND CreateTabControl(HWND hwndParent) 
{ 
RECT rcClient; 
INITCOMMONCONTROLSEX icex; 
HBITMAP bmpMain; 
HIMAGELIST hwndImageList; 
TCITEM tie; 

/* Initialize common controls */ 
icex.dwSize = sizeof(INITCOMMONCONTROLSEX); 
icex.dwICC = ICC_TAB_CLASSES; 
InitCommonControlsEx(&icex); 

/* Create a TabControl of child window size */ 
GetClientRect(hwndParent, &rcClient); 

hwndTabControl = CreateWindowEx (
      0, 
      WC_TABCONTROL, 
      "", 
      WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, 
      0, 0, rcClient.right, rcClient.bottom, 
      hwndParent, NULL, hInstance, NULL); 

if (hwndTabControl == NULL) 
{ 
    return NULL; 
}; 

/* Create ImageList */ 
hwndImageList = ImageList_Create(12, 9, ILC_COLOR24 | ILC_MASK, 0, 1); 
bmpMain =(HBITMAP) LoadImage(NULL, "0.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); 
ImageList_AddMasked(hwndImageList, bmpMain, RGB(255, 255, 255)); 

/* Add Tabs to panel */ 
tie.mask = TCIF_TEXT | TCIF_IMAGE; 
tie.iImage = 0; 
tie.pszText = "Untitled"; 

if ((TabCtrl_InsertItem(hwndTabControl, 0, &tie) == -1) || (TabCtrl_SetImageList(hwndTabControl, hwndImageList))) 
{ 
     DestroyWindow(hwndTabControl); 
     return NULL; 
} 

/* PanelTab Default font */ 
SendMessage(hwndTabControl, WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(1,0)); 

return hwndTabControl; 
} 

ich gerade geändert:

fill_out_present(&present, hwnd); 

zu

fill_out_present(&present, hwndTabControl); 

aber Raster ist auf das ganze Formularfenster gezeichnet ... und Ich will es in Panel-Registerkarte Index 0 ... ich denke, ich muss Index geben, welche Linien gezogen werden müssen ... Ich bekomme das auf der linken Seite und ich muss das auf rechtes Bild bekommen.

enter image description here

Antwort

0

Verwenden TabCtrl_AdjustRect das Client-Rechteck auf den tatsächlichen Anzeigebereich einzustellen, bevor die Berechnungen für Breite/Höhe und Linie Start-/Endpunkte tun:

RECT rc; 
GetClientRect(hwndTabControl, &rc); // rc will be set to the client area of the tab control 
TabCtrl_AdjustRect(hwndTabControl, FALSE, &rc); // rc will be adjusted to the actual display area of the tab control 

Derzeit ist das Client-Rechteck des Registerkarte Die Steuerung beginnt bei 0,0, während Sie eigentlich wollen, dass sie an dem Offset beginnt, an dem der eigentliche Anzeigebereich beginnt. Deshalb zeichnest du die ganze Form.

+0

Danke ... ich versuche deinen Vorschlag zu benutzen und ich denke ich mache es irgendwo falsch..ich habe den ganzen cpp Quellcode hochgeladen ... könntest du einen Blick darauf werfen wo ich es falsch mache? Es ist das gleiche Verhalten wie in Bild oben gepostet ... Link https://ufile.io/md1lm – John

+0

Ich fand in MSDN win32 API, die ich für jedes TabControl Kind Dialogfeld konstruieren muss und dann ziehe ich Linien auf aktuelle ausgewählt tab-dialogfeld ... ich habe das Dialogfeld verpasst, und hier werden Komponenten hinzugefügt ... ich sehe jetzt, dass ich Linien auf die gesamte Breite und Höhe von TabControl zeichne und deshalb Gitternetzlinien über TabControl..wenn ich mit dem Hinzufügen von Dialog fertig bin Box ich werde es hier hinzufügen – John

Verwandte Themen