Jump to content
  • Advertisement
Sign in to follow this  

win32 blue background

This topic is 2389 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am getting an error with this line of code.
[font="Consolas"][font="Consolas"]HBRUSH CreateBrushIndirect([/font][/font][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"]const[/font][/font][/font][font="Consolas"][font="Consolas"] LOGBRUSH *lplb);

[font="Consolas"][size="1"][font="Consolas"][size="1"]

c:\users\phil\documents\visual studio 2010\projects\win32\win32\win32.cpp(7): error C2373: 'CreateBrushIndirect' : redefinition; different type modifiers

c:\program files (x86)\microsoft sdks\windows\v7.0a\include\wingdi.h(3251) : see declaration of 'CreateBrushIndirect'



[/font][/font][/font][/font]

Share this post


Link to post
Share on other sites
Advertisement
HBRUSH is the return type. It looks like you have placed a re-declaration of the function where you would like to call the function.

Try this instead:
Where log_brush is the LOGBRUSH structure containing the information about the brush you would like to create a copy of


HBRUSH new_brush;
new_brush = CreateBrushIndirect(&log_brush);


If you're looking to create a specific colored brush, tho, I would recommend using something like CreateSolidBrush, for which the syntax is simpler and more to the point:


HBRUSH created_brush = CreateSolidBrush(RGB(0, 0, 255));

Share this post


Link to post
Share on other sites
well I am attempting to draw a blue background with three diferent windows.
here is my code
#include <windows.h>

#include "resource.h"

HWND ghMainWnd = 0;

HINSTANCE ghAppInst = 0;

HWND ghMainWnd2 = 0;

HINSTANCE ghAppInst2 = 0;

//HBRUSH CreateBrushIndirect(const LOGBRUSH *lplb);

LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)

{

switch(msg)

{

case WM_LBUTTONDOWN:

MessageBox(0,"You clicked Window #1","Msg",MB_OK);

return 0;

case WM_DESTROY:

PostQuitMessage(0);

return 0;

case WM_KEYDOWN:

if(wParam==VK_ESCAPE)

MessageBox(0,"Exit Program","Msg",MB_YESNO);

if(IDYES)

{

DestroyWindow(ghMainWnd);

return 0;

break;

}

if(IDNO)

{

break;

return 0;

}

}

return DefWindowProc(hWnd,msg,wParam,lParam);

}

LRESULT CALLBACK WndProc2(HWND hWnd2,UINT msg2, WPARAM wParam2, LPARAM lParam2)

{

switch(msg2)

{

case WM_LBUTTONDOWN:

MessageBox(0,"You clicked Window #2","Msg",MB_OK);

return 0;

case WM_DESTROY:

PostQuitMessage(0);

return 0;

case WM_KEYDOWN:

if(wParam2==VK_ESCAPE)

MessageBox(0,"Exit Program","Msg",MB_YESNO);

if(IDYES)

{

DestroyWindow(ghMainWnd2);

return 0;

break;

}

if(IDNO)

{

break;

return 0;

}

}

return DefWindowProc(hWnd2,msg2,wParam2,lParam2);

}

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR cmdLine,int showCmd)

{



ghAppInst = hInstance;

WNDCLASS wc;

wc.style = CS_HREDRAW | CS_VREDRAW;

wc.lpfnWndProc = WndProc;

wc.cbClsExtra = 0;

wc.cbWndExtra = 0;

wc.hInstance = ghAppInst;

wc.hIcon = :: LoadIcon (ghAppInst,MAKEINTRESOURCE(IDI_ICON1));

wc.hCursor = :: LoadCursor(0,IDC_ARROW);

wc.hbrBackground = (HBRUSH)::GetStockObject(BLACK_BRUSH);

wc.lpszMenuName = 0;

wc.lpszClassName = "MyWndClassName";

RegisterClass (&wc);

ghAppInst2 = hInstance;

WNDCLASS wc2;

wc2.style = CS_HREDRAW | CS_VREDRAW;

wc2.lpfnWndProc = WndProc2;

wc2.cbClsExtra = 0;

wc2.cbWndExtra = 0;

wc2.hInstance = ghAppInst2;

wc2.hIcon = :: LoadIcon (0,IDI_APPLICATION);

wc2.hCursor = :: LoadCursor(0,IDC_ARROW);

wc2.hbrBackground = (HBRUSH)::GetStockObject(BLACK_BRUSH);

wc2.lpszMenuName = 0;

wc2.lpszClassName = "MyWndClassName";

RegisterClass (&wc2);

ghMainWnd = :: CreateWindow("MyWndClassName","Window 1",WS_OVERLAPPEDWINDOW|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL,100,200,400,400,0,0,ghAppInst,0);

if(ghMainWnd == 0)

{

::MessageBox(0,"CreateWindow - Failed",0,0);

return false;

}

ghMainWnd2 = :: CreateWindow("MyWndClassName","Window 2",WS_OVERLAPPEDWINDOW|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL,500,200,400,400,0,0,ghAppInst2,0);

if(ghMainWnd2 == 0)

{

::MessageBox(0,"CreateWindow - Failed",0,0);

return false;

}

ghMainWnd = :: CreateWindow("MyWndClassName","Window 3",WS_OVERLAPPEDWINDOW|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL,900,200,400,400,0,0,ghAppInst,0);

if(ghMainWnd == 0)

{

::MessageBox(0,"CreateWindow - Failed",0,0);

return false;

}

ShowWindow(ghMainWnd,showCmd);

UpdateWindow(ghMainWnd);

ShowWindow(ghMainWnd2,showCmd);

UpdateWindow(ghMainWnd2);

MSG msg;

ZeroMemory(&msg,sizeof(MSG));

while(GetMessage(&msg,0,0,0))

{

TranslateMessage(&msg);

DispatchMessage(&msg);

}

return (int)msg.wParam;

}

?

?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!