Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is Win32?

Answer Posted / nandu

// 2109a1.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "2109a1.h"
#include <windows.h>
#include "resource.h"
#include "stdio.h"
#include "stdlib.h"
#include <string>
#include <stdio.h>
#include <sstream>

//#include <boost/spirit/include/qi.hpp>

#define ID_EDIT 1
#define ID_BUTTON 2
#define ID_SQUARE 3
#define ID_CIRCLE 4
#define ID_CHECK 5
#define ID_RED 6
#define ID_GREEN 7
#define WM_CTLCOLORBTN 8
#define WM_CTLCOLORBTN1 9
#define ID_PAINT 10
#define ID_LIST 11
#define ID_LISTVIEW 12
HWND hWnd1;
LRESULT _stdcall MyWindowFun(HWND,UINT,WPARAM,LPARAM);
LRESULT _stdcall ChWndProc(HWND,UINT,WPARAM,LPARAM);
LRESULT _stdcall EditProc (HWND, UINT, WPARAM, LPARAM);


int iCurrectcheck=0 ;
int shape=0;
int color=0;
std::wstring STR;
TCHAR szAppName[] = TEXT ("PopPad1") ;
WNDPROC OldEdit ;
HINSTANCE g_hInstance = NULL;
HWND g_hwnd = NULL;
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
LPSTR lpCmdLine,int nShowCmd)
{
WNDCLASS wc = {0};
WNDCLASS chwc = {0};
HWND hwnd;
MSG msg;

g_hInstance = hInstance;

wc.hInstance = hInstance;
wc.hbrBackground = CreateSolidBrush(RGB(255,255,255));
wc.lpfnWndProc = MyWindowFun;
wc.lpszClassName = L"kishore";
wc.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wc.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
//wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);

chwc.hInstance = hInstance;
chwc.hbrBackground = CreateSolidBrush(RGB(0,255,255));
chwc.lpfnWndProc = ChWndProc;
chwc.lpszClassName = L"trust";

RegisterClass(&wc);
RegisterClass(&chwc);

hwnd = CreateWindow(L"kishore",L"My
Window",WS_OVERLAPPEDWINDOW,
0,0, CW_USEDEFAULT,
0,NULL,LoadMenu(hInstance,MAKEINTRESOURCE(IDR_MENU1)),hInstance,NULL);

ShowWindow(hwnd,SW_SHOW);
while(GetMessage(&msg,0,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;

}

void PaintWindow(HWND hWn,std::wstring Name,int shape1,int
color1,int check1)
{

HDC hdc;
RECT rect ;
HBRUSH hBrush ;
hdc = GetDC(hWnd1);

GetClientRect (hWnd1, &rect) ;
float value = 0;
std::wstringstream converter;

converter << Name;
converter >> value;
if(check1 == 1)
{
if(color1 == 1)
{
hBrush = CreateSolidBrush(RGB(255,0,0));
hBrush = (HBRUSH) SelectObject (hdc, hBrush) ;
}
if(color1 == 2)
{
hBrush = CreateSolidBrush(RGB(0,255,0));
hBrush = (HBRUSH) SelectObject (hdc, hBrush) ;
}
//hBrush = (HBRUSH) SelectObject (hdc, hBrush) ;
}
if(shape1 == 1)
Rectangle(hdc,250,250,250+(int)value,250+(int)value);
if(shape1 == 2)
Ellipse(hdc,250,250,250+(int)value,250+(int)value);
//DeleteObject(SelectObject (hdc, hBrush)) ;

ReleaseDC(hWnd1,hdc);

}
void PaintTheBlock (HWND hWn,std::wstring Name,int
shape2,int color2,int check2)
{
InvalidateRect (hWn, NULL, TRUE) ;
UpdateWindow (hWn) ;
PaintWindow (hWn, Name, shape2, color2,check2);
}




LRESULT _stdcall MyWindowFun(HWND hwnd,UINT nMessage,WPARAM
wp,LPARAM lp)
{
int wmId, wmEvent;
PAINTSTRUCT ps ;
//HDC hdc;
hWnd1 = hwnd;
switch( nMessage )
{
case WM_COMMAND:
wmId = LOWORD(wp);
wmEvent = HIWORD(wp);
switch (wmId)
{
case ID_DIALOG_SHOW:
if ( g_hwnd == NULL )
{
g_hwnd = CreateWindow(L"trust",L"Child Window",WS_CHILD
| //WS_OVERLAPPED
DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP |
WS_CAPTION |
WS_SYSMENU,20,60,550,200,hwnd,NULL,g_hInstance,NULL);

}
ShowWindow(g_hwnd,SW_SHOW);
InvalidateRect (hwnd, NULL, TRUE) ;
default:
return DefWindowProc(hwnd,nMessage, wp, lp);
}



case WM_CLOSE:
if ( IDOK == MessageBox(hwnd,L"Do you want to close
???",L"Close",MB_OKCANCEL) )
{
return DefWindowProc(hwnd,nMessage,wp,lp);
}
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hwnd,nMessage,wp,lp);
}
}



LRESULT _stdcall ChWndProc(HWND hwnd,UINT nMessage,WPARAM
wp,LPARAM lp)
{
static HWND hwndEdit ;
static HWND hwndButton;
static HWND hwndRadio1;
static HWND hwndRadio2;
static HWND hwndcheck;
static HWND hwndRadio3;
static HWND hwndRadio4;
static HWND hwndgroup1;
static HWND hwndgroup2;
static HWND hListBox;
static HWND hListView;
/*static HWND hCtrl ;
static HWND hCtrl1 ;*/
static int iSquare ;
static int iCircle ;
static int iRed ;
static int iGreen ;
static int check ;
static HWND hCtrlBlock ;

switch(nMessage)
{

case WM_CREATE :
hwndEdit = CreateWindow (TEXT ("edit"), NULL,
WS_CHILD | WS_VISIBLE | //WS_HSCROLL | WS_VSCROLL |
WS_BORDER | ES_LEFT |
ES_MULTILINE |ES_NUMBER |
ES_AUTOHSCROLL | ES_AUTOVSCROLL,
0, 0, 0, 0, hwnd, (HMENU) ID_EDIT,
((LPCREATESTRUCT) lp) -> hInstance, NULL) ;

hwndButton=CreateWindow(
L"BUTTON",
L"OK",
WS_TABSTOP|WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON,
0, 0, 0, 0, hwnd,
(HMENU) ID_BUTTON,
NULL,NULL);
hwndRadio1 = CreateWindowEx(0,
TEXT("BUTTON"),
TEXT("SQUARE!"),
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON | WS_TABSTOP
| WS_GROUP,
0, 0, 0, 0,
hwnd,
(HMENU) ID_SQUARE,
NULL,NULL);

hwndRadio2 = CreateWindowEx(0,
TEXT("BUTTON"),
TEXT("CIRCLE!"),
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
0, 0, 0, 0,
hwnd,
(HMENU) ID_CIRCLE,
NULL,NULL);

hwndgroup1 = CreateWindow(L"BUTTON", L"", WS_CHILD |
WS_VISIBLE | BS_GROUPBOX,
9, /* X Position */
35, /* Y Position */
234, /* X Width */
42, /* Y Height */
hwnd, (HMENU) WM_CTLCOLORBTN,((LPCREATESTRUCT)
lp) -> hInstance, NULL);
hwndgroup2 = CreateWindow(L"BUTTON", L"", WS_CHILD |
WS_VISIBLE | BS_GROUPBOX,
9, /* X Position */
105, /* Y Position */
234, /* X Width */
42, /* Y Height */
hwnd, (HMENU) WM_CTLCOLORBTN1,((LPCREATESTRUCT)
lp) -> hInstance, NULL);

hwndcheck = CreateWindowEx(
0,
TEXT("BUTTON"),
TEXT("COLOR!"),
WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX,// |
BS_OWNERDRAW,
0, 0, 0, 0,
hwnd,
(HMENU)ID_CHECK,
NULL,
NULL
);
hwndRadio3 = CreateWindowEx(0,
TEXT("BUTTON"),
TEXT("RED!"),
WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP,
0, 0, 0, 0,
hwnd,
(HMENU) ID_RED,
NULL,NULL);
hwndRadio4 = CreateWindowEx(0,
TEXT("BUTTON"),
TEXT("GREEN!"),
WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP,
0, 0, 0, 0,
hwnd,
(HMENU) ID_GREEN,
NULL,NULL);

hListBox = CreateWindowEx(WS_EX_CLIENTEDGE
, L"LISTBOX", NULL
, WS_CHILD | WS_VISIBLE //| ES_VSCROLL | ES_AUTOVSCROLL
,250,15, 250, 140
, hwnd, (HMENU) ID_LIST, NULL, NULL);

return 0;

OldEdit = (WNDPROC) SetWindowLong (hwndEdit, GWL_WNDPROC,
(LPARAM) EditProc) ;


case WM_SIZE :
MoveWindow (hwndEdit, 15,15, 100, 20, TRUE) ;
MoveWindow (hwndButton, 135,15, 100, 20, TRUE) ;
MoveWindow (hwndRadio1, 15,50, 100, 20, TRUE) ;
MoveWindow (hwndRadio2, 135,50, 100, 20, TRUE) ;
MoveWindow (hwndcheck, 75,85, 100, 20, TRUE) ;
MoveWindow (hwndRadio3, 15,120, 100, 20, TRUE) ;
MoveWindow (hwndRadio4, 135,120, 100, 20, TRUE) ;
return 0 ;
case WM_INITDIALOG:
hCtrlBlock = GetDlgItem (g_hwnd, ID_PAINT) ;
return (INT_PTR)TRUE;

case WM_COMMAND:

//SetDlgItemText(hListBox, ID_LIST, L"This is a string");
//SetWindowText(hListBox, L"Press Me Again!");
switch (LOWORD (wp))
{
case ID_SQUARE:
iSquare = SendMessage (hwndRadio1, BM_GETCHECK, 0, 0);
iCircle=0;
//SetFocus((HWND)BM_GETCHECK);
return TRUE;
case ID_CIRCLE:
iCircle = SendMessage (hwndRadio2, BM_GETCHECK, 0, 0);
iSquare=0;
return TRUE;
case ID_CHECK:
check = SendMessage (hwndcheck, BM_GETCHECK, 0, 0);
if(check == 1)
{
ShowWindow(hwndRadio3,SW_SHOW);
ShowWindow(hwndRadio4,SW_SHOW);

}
if(check == 0)
{
ShowWindow(hwndRadio3,SW_HIDE);
ShowWindow(hwndRadio4,SW_HIDE);

}

return TRUE;
case ID_RED:
iRed = SendMessage (hwndRadio3, BM_GETCHECK, 0, 0);
iGreen=0;

return TRUE;
case ID_GREEN:
iGreen = SendMessage (hwndRadio4, BM_GETCHECK, 0, 0);
iRed=0;

return TRUE;


case ID_BUTTON:

int LEN = 100;
TCHAR ARR[100];
std::wstring MIX;
std::wstring TSquare1;
std::wstring TCircle1;
std::wstring TRed1;
std::wstring TGreen1;

shape=0;
color=0;
/*iCurrectcheck=check ;*/
GetDlgItemText(g_hwnd, ID_EDIT,(LPWSTR)ARR, LEN);

STR = ARR;
if(iSquare==1)
{
shape=1;
iCircle=0;
TSquare1 = TEXT (" Square") ;
}
else if(iCircle==1)
{
shape =2;
iSquare=0;
TCircle1 = TEXT (" Circle") ;
}
if(iRed==1)
{
color=1;
iGreen=0;
if(check==1)
TRed1 = TEXT (" Red Color") ;
}
else if(iGreen==1)
{
color =2;
iRed=0;
if(check==1)
TGreen1 = TEXT (" Green Color") ;
}
MIX = STR +L" Size" + TRed1 + TGreen1+ TSquare1 + TCircle1 ;
LPCWSTR Insert = &MIX[0];
SendMessage (hListBox, LB_ADDSTRING, 0,(LPARAM)Insert);
PaintTheBlock(hCtrlBlock, STR, shape, color,check);
EndDialog (g_hwnd, TRUE) ;
return TRUE;
}
return 0 ;
case WM_CLOSE:
DefWindowProc(g_hwnd,nMessage,wp,lp);
g_hwnd = NULL;
return 0;
default:
return DefWindowProc(hwnd,nMessage,wp,lp);
}
}
LRESULT _stdcall EditProc (HWND g_hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
return CallWindowProc (OldEdit, g_hwnd, message, wParam,
lParam) ;
}

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is preemption and context switching?

1112


What is System call executable binary file into a process?

1174


what is the stack size in win 32 program

1368


What is an Hash Mapping in java?

3071


What is GDI object?

1088


explain WM_PAINT message ?????

3178


What is Function entry for DLL in win3.1?

1106


to take three string inputs in a two dimensional array of 3 rows and 15 columns and write a function that prints them.

2587


What Message to limit the size of window?

1106