谁能给个不用MFC接受用户输入的窗口?

sjd163 2003-06-01 09:36:15
谁能给个不用MFC接受用户输入的窗口?
...全文
28 15 打赏 收藏 举报
写回复
15 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
sjd163 2003-06-04
试一试
  • 打赏
  • 举报
回复
skybblue 2003-06-04
GetWindowText函数,你以前用VC编程序吗?
  • 打赏
  • 举报
回复
skybblue 2003-06-04
我给你发送的那个例子中,就有这两个函数!
  • 打赏
  • 举报
回复
sjd163 2003-06-04
现在有窗口了。问题是如何将其中输入的东西取出来。
  • 打赏
  • 举报
回复
sjd163 2003-06-04
经查CreateWindow和CreateWindowEx可以接受输入。
谁能给个例子。
谢谢!
  • 打赏
  • 举报
回复
skybblue 2003-06-04
程序已经改好,给你发过去了!你收一下!
  • 打赏
  • 举报
回复
skybblue 2003-06-02
你早说呀!
  • 打赏
  • 举报
回复
sjd163 2003-06-02
注意:是ATL COM AppWizard 编程遇到的问题。
  • 打赏
  • 举报
回复
oiq 2003-06-02
===================================================
Digit Pro space 欢迎您
http://www.dpspace.com
有什么问题到论坛上发表,我将尽我全力为您解决
论坛欢迎高手注册加入,让我们共同进步
  • 打赏
  • 举报
回复
sjd163 2003-06-02
up
  • 打赏
  • 举报
回复
skybblue 2003-06-02
#include "stdafx.h"
#include "resource.h"

#define MAX_LOADSTRING 100

// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
HWND hEditWnd = NULL;

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

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;

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

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

hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_WIN32TEST);

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

return msg.wParam;
}



//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);

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

return RegisterClassEx(&wcex);
}

//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
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;
}

//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);

switch (message)
{
case WM_CREATE:
{
RECT rect;
GetClientRect(hWnd,&rect);
hEditWnd = CreateWindowEx(WS_EX_LEFT|WS_EX_LTRREADING|WS_EX_RIGHTSCROLLBAR|WS_EX_NOPARENTNOTIFY|WS_EX_CLIENTEDGE,
_T("Edit"),_T("Edit"),WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|ES_LEFT|ES_WANTRETURN|ES_MULTILINE|WS_HSCROLL|WS_VSCROLL,
0,0,rect.right - rect.left ,rect.bottom - rect.top,hWnd,NULL,NULL,0);
//
}
//MessageBox(hWnd,"test","test",MB_OK);
break;
case WM_SIZE:
MoveWindow(hEditWnd,0,0,LOWORD(lParam),HIWORD(lParam),TRUE);
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)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...
RECT rt;
GetClientRect(hWnd, &rt);
DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

// Mesage handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;

case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
  • 打赏
  • 举报
回复
windbells 2003-06-01
在窗口回调函数里对应写消息处理代码。

#include <windows.h>
#include <tchar.h>

TCHAR szWinName[]="MyWin";


int APIENTRY WinMain(HINSTANCE hThisInst,HINSTANCE hPrevInst,LPSTR lpszArgs,int nWinMode)
{
HWND hwnd;
MSG msg;
int cxScreen = ::GetSystemMetrics(SM_CXSCREEN);//获得屏幕宽
int cyScreen = ::GetSystemMetrics(SM_CYSCREEN); //获得屏幕高
WNDCLASSEX wcl;
wcl.cbSize=sizeof(WNDCLASSEX);
wcl.hInstance = hThisInst;
wcl.lpszClassName = szWinName;
wcl.lpfnWndProc = (WNDPROC)WindowFunc;
wcl.style = CS_HREDRAW | CS_VREDRAW;
wcl.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wcl.hCursor = LoadCursor(NULL,IDC_ARROW);
wcl.hbrBackground = (HBRUSH)(GRAY_BRUSH);
wcl.lpszMenuName = NULL;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
wcl.hIconSm = LoadIcon(wcl.hInstance,IDI_APPLICATION);
if(!RegisterClassEx(&wcl))
{
DWORD a;
a=GetLastError();
return 0;
}
hwnd = CreateWindowEx(WS_EX_TOOLWINDOW|WS_EX_TOPMOST,szWinName,szWinName,WS_POPUPWINDOW,0,0,cxScreen,cyScreen,HWND_DESKTOP,NULL,hThisInst,NULL);
ShowWindow(hwnd,1);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WindowFunc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_CREATE:
break;
case WM_DESTROY:
break;




default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}
  • 打赏
  • 举报
回复
qrlvls 2003-06-01
不是用Windows提供了API函数来搞掂哦
上面的兄弟给了SDK的结构出来,至于创建文本框只要使用编辑框的窗口类就行了,方法一样
  • 打赏
  • 举报
回复
skybblue 2003-06-01
你可以用Win32 API程序创建一个框架不就知道了吗!
  • 打赏
  • 举报
回复
sjd163 2003-06-01
怎么用还是不知道。能详细点吗?
  • 打赏
  • 举报
回复
发帖
ATL

3233

社区成员

ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
帖子事件
创建了帖子
2003-06-01 09:36
社区公告
暂无公告