|
Thanks!
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
Hi ... can any1 tell me what is wrong with the following code? i'm sure its some silly mistake that i made ... I am trying to create a Richedit control in a window. I have included richedit.h and my code compiles successfully. but _hWnd remains NULL after this call ... i am using Microsoft VC++ 6 with the Platform SDK 2003 installed. please help me out. thankx in advance.
_hWnd = CreateWindowEx(WS_EX_CLIENTEDGE,
RICHEDIT_CLASS,
TEXT("AA"),
WS_CHILD | WS_VISIBLE | ES_MULTILINE,
10, 10,
100, 100,
_parent,
0,
(HINSTANCE)::GetModuleHandle(0),
0);
-Tareq
|
|
|
|
|
|
After using the following code from MSDN to retrieve the last error right after CreateWindowEx, i get "Invalid Window Handle".
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0,
NULL );
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
LocalFree( lpMsgBuf );
-Tareq
|
|
|
|
|
This seems to suggest that the parent window has not been created yet. Where are you calling the function from?
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Here is the code ...
#define WIN32_LEAN_AND_MEAN
#include < windows.h >
#include < stdlib.h >
#include < richedit.h >
#include < commctrl.h >
HWND _rich;
HMODULE _hRich;
char className[14];
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
_rich = CreateWindowEx(WS_EX_CLIENTEDGE,
className,
"Sample Text",
WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_BORDER | WS_VSCROLL,
10, 10,
200, 200,
hWnd,
0,
GetModuleHandle(0),
0);
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0,
NULL );
MessageBox(
NULL,
(LPCTSTR)lpMsgBuf,
"Error",
MB_OK | MB_ICONINFORMATION
);
LocalFree( lpMsgBuf );
break;
case WM_CLOSE:
DestroyWindow(hWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASSEX wc;
HWND _hWnd;
ZeroMemory(className, 14);
InitCommonControls();
_hRich = LoadLibrary("RICHED20.DLL");
if (!_hRich)
{
_hRich = LoadLibrary("RICHED32.DLL");
if (!_hRich)
{
MessageBox(0, "Richedit control not loaded!", "Error", MB_ICONERROR);
exit(0);
}
else
{
strcpy(className, "RichEdit");
}
}
else
{
strcpy(className, "RICHEDIT_CLASS");
}
wc.cbClsExtra = 0;
wc.cbSize = sizeof(WNDCLASSEX);
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wc.hCursor = 0;
wc.hIcon = 0;
wc.hIconSm = 0;
wc.hInstance = hInstance;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.lpszClassName = "MainWindowClass";
wc.lpszMenuName = 0;
wc.style = 0;
if (!RegisterClassEx(&wc))
{
MessageBox(0, "Error", "", MB_ICONERROR);
exit(0);
}
_hWnd = CreateWindowEx(WS_EX_WINDOWEDGE,
"MainWindowClass",
"",
WS_OVERLAPPEDWINDOW,
0, 0,
300, 300,
0, 0,
hInstance, 0);
ShowWindow(_hWnd, SW_SHOW);
UpdateWindow(_hWnd);
MSG msg;
while (GetMessage(&msg, 0, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
-Tareq
|
|
|
|
|
This code won't work. You'll get an error message saying that you're using an unknown class. You need to change
strcpy(className, "RICHEDIT_CLASS");
to
strcpy(className, RICHEDIT_CLASS);
I tried this and it worked fine.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
thankx a lot man ... i knew it was a silly mistake!!!
-Tareq
|
|
|
|
|
Did you init richedit control??
if you use MFC, please try to call AfxInitRichedit() in App::InitInstance().
maybe that's the point.
|
|
|
|
|
No MFC. Just Win32.
-Tareq
|
|
|
|
|
try to use "InitCommonControlsEx();" in your InitInstance() function.
|
|
|
|
|
nope its the same.
-Tareq
|
|
|
|
|
try
::LoadLibrary("Riched20.dll");
For win95 the rich edit control lib is "Riched32.dll",
for win98 win2k&winxp, the lib is "Riched20.dll"
|
|
|
|
|
tried that also ... i'm sure its some silly mistake. it cant be that complicated.
HINSTANCE hLib;
hLib = LoadLibrary("Riched20.dll");
if (!hLib)
{
hLib = LoadLibrary("Riched32.dll");
if (!hLib)
{
MessageBox(0, "Richedit control failed to initialize!", "Editor", MB_ICONERROR);
exit(0);
}
else
strcpy(_className, "RichEdit");
}
else
{
strcpy(_className, "RICHEDIT_CLASS");
}
-Tareq
|
|
|
|
|
Hi,
I'm looking for an easy way to test my embedded C code.
I have figured out how to get my C code complied into MFC VC6.0, now I would like to take the native C "printf" (for debugging) and display it in a MFC list or text box. I don't care which one
I'm only after debug output and being able to push MFC buttons.
Please help me with a simple way to do this. I'm not an expert C++ programer.
|
|
|
|
|
use console output option;
#include <windows.h>
void NewLine(void);
void ScrollScreenBuffer(HANDLE, INT);
HANDLE hStdout, hStdin;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
void main(void)
{
LPSTR lpszPrompt1 = "Type something and press Enter:\n";
LPSTR lpszPrompt2 = "Type any key: ";
CHAR chBuffer[256];
DWORD cRead, cWritten, fdwMode, fdwOldMode;
WORD wOldColorAttrs;
// Get handles to STDIN and STDOUT.
hStdin = GetStdHandle(STD_INPUT_HANDLE);
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
if (hStdin == INVALID_HANDLE_VALUE ||
hStdout == INVALID_HANDLE_VALUE)
{
MyErrorExit("GetStdHandle");
}
// Save the current text colors.
if (! GetConsoleScreenBufferInfo(hStdout, &csbiInfo))
MyErrorExit("GetConsoleScreenBufferInfo");
wOldColorAttrs = csbiInfo.wAttributes;
// Set the text attr. to draw red text on black background.
if (! SetConsoleTextAttribute(hStdout, FOREGROUND_RED))
MyErrorExit("SetConsoleTextAttribute");
// Write to STDOUT and read from STDIN by using the default
// modes. Input is echoed automatically, and ReadFile
// does not return until a carriage return is typed.
//
// The default input modes are line, processed, and echo.
// The default output modes are processed and wrap at EOL.
while (1)
{
if (! WriteFile(
hStdout, // output handle
lpszPrompt1, // prompt string
lstrlen(lpszPrompt1), // string length
&cWritten, // bytes written
NULL) ) // not overlapped
break;
if (! ReadFile(
hStdin, // input handle
chBuffer, // buffer to read into
255, // size of buffer
&cRead, // actual bytes read
NULL) ) // not overlapped
break;
if (chBuffer[0] == 'q') break;
}
// Turn off the line input mode, and echo the input mode.
if (! GetConsoleMode(hStdin, &fdwOldMode))
MyErrorExit("GetConsoleMode");
fdwMode = fdwOldMode &
~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT);
if (! SetConsoleMode(hStdin, fdwMode))
MyErrorExit("SetConsoleMode");
// Prompt for input.
if (! WriteFile(
hStdout, // output handle
lpszPrompt2, // prompt string
lstrlen(lpszPrompt2), // string length
&cWritten, // bytes written
NULL) ) // not overlapped
MyErrorExit("WriteFile");
// Without line and echo input modes, ReadFile returns
// when any input is available. Carriage returns must
// be handled, and WriteFile is used to echo input.
while (1)
{
if (! ReadFile(hStdin, chBuffer, 1, &cRead, NULL))
break;
if (chBuffer[0] == '\r')
NewLine();
else if (! WriteFile(hStdout, chBuffer, cRead,
&cWritten, NULL)) break;
if (chBuffer[0] == 'q') break;
}
// Restore the original console mode.
if (! SetConsoleMode(hStdin, fdwOldMode))
MyErrorExit("SetConsoleMode");
// Restore the original text colors.
if (! SetConsoleTextAttribute(hStdout, wOldColorAttrs))
MyErrorExit("SetConsoleTextAttribute");
}
// The NewLine function handles carriage returns when the processed
// input mode is disabled. It gets the current cursor position
// and resets it to the first cell of the next row.
void NewLine(void)
{
if (! GetConsoleScreenBufferInfo(hStdout, &csbiInfo))
MyErrorExit("GetConsoleScreenBufferInfo");
csbiInfo.dwCursorPosition.X = 0;
// If it is the last line in the screen buffer, scroll
// the buffer up.
if ((csbiInfo.dwSize.Y-1) == csbiInfo.dwCursorPosition.Y)
{
ScrollScreenBuffer(hStdout, 1);
}
// Otherwise, advance the cursor to the next line.
else csbiInfo.dwCursorPosition.Y += 1;
if (! SetConsoleCursorPosition(hStdout,
csbiInfo.dwCursorPosition))
{
MyErrorExit("SetConsoleCursorPosition");
}
}
|
|
|
|
|
stupid question here?
where would I start to get an editbox receiving strings one line at a time to display the last line. example
1<br />
2<br />
3<br />
4<br />
5<br />
6<br />
7
right now line 6 and 7 are out of view in the editbox, but I want the editbox to show 6 and 7, and hide 1 and 2. In other words just auto display the last messages sent to the editbox.
thanks, JoeSox
dev in VC++ 6.0
|
|
|
|
|
Did you try out CEdit::LineScroll(...)?
from msdn:
void LineScroll(int nLines, int nChars = 0);<br />
<br />
Parameters:<br />
nLines <br />
Specifies the number of lines to scroll vertically. <br />
nChars<br />
<br />
Specifies the number of character positions to scroll horizontally. This value is ignored if the edit control has either the ES_RIGHT or ES_CENTER style.
Weiye, Chen
When pursuing your dreams, don't forget to enjoy your life...
|
|
|
|
|
thanks, I've decided to use this.
Later, JoeSox www.humanaiproject.org
"Dream as if you'll live forever; live as if you'll die tomorrow."
- James Dean(ISTP)
|
|
|
|
|
just use WM_VSCROLL like this:
::SendMessage(WM_VSCROLL,hWnd,SB_BOTTOM,0);
the hWnd is the handle of edit box;
good luck!
|
|
|
|
|
thanks
Later, JoeSox www.humanaiproject.org
"Dream as if you'll live forever; live as if you'll die tomorrow."
- James Dean(ISTP)
|
|
|
|
|
Recently I meet a problem, that is:
How can a ropertySheet instance be added to a CPropertySheet as a CPropertyPage?
Who can tell me this promblem and its realization?
|
|
|
|
|
|
Yeah, that is the point!
It is so perfect!
Thank you very much!
LeonOrient
|
|
|
|
|
for program to ras monitoring
end term create is 15.06.2003
more info: balu2@o2.pl
|
|
|
|
|