WinAPI Kompnenty jak w win 95/98

0

Witam, mam pytanie jak uaktywnić nie domyślne komponenty ?

Do programu dodałem taką linie:

#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' " "version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

Ale niestety static text dalej wygląda jak w win 95/98 zaś w buttonie poprawnie wyglądającym tekst jest taki jakby bold.

Proszę o pomoc.

0
  1. pokaż jakiś kod, albo obrazek jak to wygląda u ciebie
  2. jaki kompilator?
0

Jeśli używasz precompiled headers, to właśnie zauważyłem że linijka musi być poniżej #include "stdafx.h" albo wewnątrz pliku stdafx.h, a nie powyżej – nie będzie działać.
Dziwne.

// test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

#include <Windows.h>

int _tmain(int argc, _TCHAR* argv[])
{
	MessageBox(GetConsoleWindow(),L"ma kota.",L"Ala",MB_OK);
	return 0;
}
0

Używam visual studio 2010, kod:

 
#include <windows.h>
#include <cmath>
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' " "version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")



static TCHAR lpszAppName[] = TEXT( "API Windows v 1.0" );
static int windowWidth = 640;
static int windowHeight = 480;
double liczba1,liczba2,wynik;
HINSTANCE hInst;
HBITMAP hBitmap;


HINSTANCE hInstance;
//buttons
HWND button1;
#define ID_BUTTON1 501
//
HWND mathOperator;
#define ID_MATHOPERATOR 601
 
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
	HDC hDC, hDC2;
	PAINTSTRUCT ps;
    switch (uMsg){	

		case WM_CREATE:
			hBitmap = (HBITMAP)LoadImage(hInst, L"logo.bmp", IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
		break;

		case WM_PAINT:
			hDC = BeginPaint(hWnd, &ps);
			Rectangle(hDC, 3,3,108,108);
			hDC2 = CreateCompatibleDC(hDC);
			SelectObject(hDC2, hBitmap);
			BitBlt(hDC,5,5,100,100,hDC2,0,0,SRCCOPY);
			DeleteObject(hDC2);
			EndPaint(hWnd, &ps);
		break;

		case WM_COMMAND:
			switch(wParam){
				case ID_BUTTON1:
					MessageBox(hWnd, L"      Application Created By \n                         Copyright @ 2013", lpszAppName, MB_OK);
				break;
				default:
				break;
			}
		break;

		

		case WM_CTLCOLORSTATIC:
			  if ((HWND)lParam == GetDlgItem(hWnd, ID_MATHOPERATOR)) {
                // we're about to draw the static
                // set the text colour in (HDC)lParam
                SetBkMode((HDC)wParam, RGB(255,255,0));
                SetTextColor((HDC)wParam, RGB(205,55,25));
                return (BOOL)CreateSolidBrush (GetSysColor(COLOR_MENU));
			  }
        break;

		case WM_CLOSE:
			if(MessageBox(hWnd,L"Czy chcesz zamknąć aplikację ?", lpszAppName, MB_YESNO) == IDYES){
				PostQuitMessage(0);
			}
		break;


        default:
            return (DefWindowProc(hWnd, uMsg, wParam, lParam));
    }
    return(0L);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    MSG   msg;
    WNDCLASS wndclass;
    HWND   hWnd;

    wndclass.style  = CS_HREDRAW | CS_VREDRAW;
    wndclass.lpfnWndProc = MainWndProc;
    wndclass.cbClsExtra = 0;
    wndclass.cbWndExtra = 0;
    wndclass.hInstance  = hInstance;
    wndclass.hIcon  = NULL;
    wndclass.hCursor  = LoadCursor(NULL, IDC_ARROW);
    wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    wndclass.lpszMenuName = NULL;
    wndclass.lpszClassName = lpszAppName;
	hInst = hInstance;


    if(RegisterClass(&wndclass) == 0)
        return FALSE;

    hWnd = CreateWindow(
        lpszAppName, lpszAppName,
        WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX,
        100, 100, windowWidth, windowHeight,
        NULL, NULL, hInstance, NULL);

    if(hWnd == NULL) {
        return FALSE;
	}else {
		//buttons
		button1 = CreateWindowEx(WS_EX_CLIENTEDGE , L"button", L"About", WS_CHILDWINDOW | WS_VISIBLE, 3, 108, 108, 20, hWnd, (HMENU) ID_BUTTON1, hInstance, NULL);
		//
		mathOperator = CreateWindowEx(WS_EX_APPWINDOW, L"static", L"+", WS_CHILDWINDOW | WS_VISIBLE, 110, 110, 50, 50, hWnd, (HMENU) ID_MATHOPERATOR, hInstance, NULL);
	}


    ShowWindow(hWnd, SW_SHOW);
    UpdateWindow(hWnd);

	

    while(GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

	

    return msg.wParam;
}

SS: user image

@nobody__, stamtąd wziąłem właśnie ten pragma comment, bo manifestu nie wiem zbytnio jak dodać

@Azarien chciałem załączyć stdafx.h ale nie mam.

1 użytkowników online, w tym zalogowanych: 0, gości: 1