What is Win32?

Answer Posted / nandu

// basic8.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "basic8.h"
#include "resource.h"
#include <windows.h>
#include "stdio.h"
//#include <string.h>
#include "stdlib.h"
#include <string>

#define ID_EDIT 1

#define MAX_LOADSTRING 100
HWND hWnd1;
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window
class name

// Forward declarations of functions included in this code
module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);

TCHAR szAppName[] = TEXT ("PopPad1") ;
WNDPROC OldEdit ;
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);

// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;

// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_BASIC8, szWindowClass,
MAX_LOADSTRING);
MyRegisterClass(hInstance);

// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}

hAccelTable = LoadAccelerators(hInstance,
MAKEINTRESOURCE(IDC_BASIC8));

// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

return (int) msg.wParam;
}



/
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);

wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance,
MAKEINTRESOURCE(IDI_BASIC8));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_BASIC8);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance,
MAKEINTRESOURCE(IDI_SMALL));

return RegisterClassEx(&wcex);
}


BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;

hInst = hInstance; // Store instance handle in our global
variable

hWnd = CreateWindow(szWindowClass, szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL,
hInstance, NULL);

if (!hWnd)
{
return FALSE;
}

ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);

return TRUE;
}


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

hWnd1 = hWnd;
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
static HWND hwndEdit ;

switch (message)
{
case WM_CREATE :
hwndEdit = CreateWindow (TEXT ("edit"), NULL,
WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |
WS_BORDER |
ES_MULTILINE |
ES_AUTOHSCROLL | ES_AUTOVSCROLL,
0, 0, 0, 0, hWnd, (HMENU) ID_EDIT,
((LPCREATESTRUCT) lParam) -> hInstance, NULL) ;

return 0 ;
case WM_SIZE :
MoveWindow (hwndEdit, 0, 0, LOWORD (lParam), HIWORD
(lParam), TRUE) ;
return 0 ;

case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);

switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case ID_CHILD_SHOW:
//if (LOWORD(wParam) == ID_CHILD_SHOW)
DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;

default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
//hWnd1 = hwndEdit;
return 0;
}

void TextPrint(HWND hWn,std::wstring Name)
{
//(LPCWSTR)
LPCWSTR Insert = &Name[0];

SetDlgItemText(hWnd1, ID_EDIT, Insert);

}

// Message handler for about box.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM
wParam, LPARAM lParam)
{
static HWND hCtrlText ;
static TCHAR Name;
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;

case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
if (LOWORD(wParam) == IDC_PRINT)
{
std::wstring STR;
std::wstring STR1;
std::wstring STR2;
std::wstring MIX;
LPWSTR st;
TCHAR* str1;
TCHAR Name[100];
TCHAR ARR[100];
TCHAR ARR1[100];
TCHAR ARR2[100];
int LEN = 100;

GetDlgItemText(hDlg, IDC_EDIT_NAME, ARR, LEN);
GetDlgItemText(hDlg, IDC_EDIT_AGE, ARR1, LEN);
GetDlgItemText(hDlg, IDC_EDIT_POST, ARR2, LEN);

STR = ARR;
//st = STR;
STR1 = ARR1;
STR2 = ARR2;
MIX = L"Name : " + STR + L"\r\n\r\n" + L"Age : " + STR1 +
L"\r\n\r\n" + L"Post : " + STR2;
TextPrint(hDlg, MIX);

EndDialog (hDlg, TRUE) ;


}
break;
}
return (INT_PTR)FALSE;
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is Function entry for DLL in win3.1?

650


What is preemption and context switching?

642


What is System call executable binary file into a process?

659


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

2146


What Message to limit the size of window?

655






What is GDI object?

677


what is the stack size in win 32 program

921


explain WM_PAINT message ?????

2751


What is an Hash Mapping in java?

2542