|
thanks, but are VAR1 and VAR2 going to be automatically recognized?
If it's broken, I probably did it
bdiamond
|
|
|
|
|
my aim is to create a key board driver, i got a program from the net and it is working but i have to focus the the keyboard events to a desired window (say ms word). what changes should i make in the following codes.
#include "mian.h"
#define MAX_COUNT 50 // Max number of keystrokes to remember
#pragma data_seg(".shared") // ".shared" is defined in exports.def to allow
// all instances of the dll to share these variables
HWND m_hHwndKey = 0;
HHOOK m_hHookKey = 0;
HWND m_hHwndMouse = 0;
HHOOK m_hHookMouse = 0;
CHAR m_szMain[MAX_COUNT] = ""; // A buffer to store decoded keyboard codes
int m_nLastPos = 0; // Last position used in the buffer
HCURSOR m_hCursorLast = 0; // These two values are used to copy the mouse
HCURSOR m_hCursorLastRet = 0; // cursor
#pragma data_seg()
// Set the values for the window and hook for the Keyboard hook
void WINAPI SetValuesKey(HWND hWnd, HHOOK hk) {
Sleep(0);
m_hHwndKey = hWnd;
m_hHookKey = hk;
}
// Set the values for the window and hook for the mouse hook
void WINAPI SetValuesMouse(HWND hWnd, HHOOK hk) {
Sleep(0);
m_hHwndMouse = hWnd;
m_hHookMouse = hk;
}
// This is the mouse hook itself
LRESULT CALLBACK MouseProc( int nCode, WPARAM wParam, LPARAM lParam ) {
Sleep(0);
if (nCode < 0) {
return CallNextHookEx(m_hHookMouse, nCode, wParam, lParam);
}
Sleep(0);
if (nCode == HC_ACTION) {
HCURSOR hCursor = GetCursor();
// Copy the mouse cursor
if (hCursor != m_hCursorLastRet) {
if (m_hCursorLast) {
DestroyCursor(m_hCursorLast);
}
ICONINFO ii;
GetIconInfo(hCursor, &ii);
m_hCursorLast = CreateIconIndirect(&ii);
DeleteObject(ii.hbmMask);
DeleteObject(ii.hbmColor);
Sleep(0);
m_hCursorLastRet = hCursor;
Sleep(0);
}
// If the message is a WM_NC*, convert it to a WM_*
if ((wParam >= 0xA0) & (wParam <= 0xA9)) {
wParam = wParam + 352;
}
// Let the listening window know about the message
Sleep(0);
PostMessage(m_hHwndMouse, wParam, 0, MAKEWPARAM(
( (MOUSEHOOKSTRUCT*) lParam )->pt.x,
( (MOUSEHOOKSTRUCT*) lParam )->pt.y));
}
return 0;
}
// Function to get the last mouse cursor that was copied. The return cursor
// is a copy of the copy, so the callee must delete it.
HCURSOR WINAPI GetLastCursor() {
Sleep(0);
HCURSOR hCursor = m_hCursorLast;
m_hCursorLast = 0;
return (hCursor);
}
// Returns the current state of the keyboard bufffer
void WINAPI GetKeyInfo(CHAR * szIn, int * nLastPos) {
Sleep(0);
memcpy(szIn, &m_szMain, MAX_COUNT);
(* nLastPos) = m_nLastPos;
}
// Keyboard hook
LRESULT CALLBACK KeyProc( int nCode, WPARAM wParam, LPARAM lParam ) {
if (nCode < 0) {
Sleep(0);
return CallNextHookEx(m_hHookKey, nCode, wParam, lParam);
}
Sleep(0);
if (nCode == HC_ACTION) {
if (lParam & 0x80000000) {
Sleep(0);
PostMessage(m_hHwndKey, WM_KEYUP, wParam, lParam);
} else {
BYTE lpKeyState[256];
GetKeyboardState((unsigned char *)&lpKeyState);
// Convert the message to a normal keystroke, and store it
// in the buffer
WORD lpChar;
int nRet = ToAscii(
wParam,
(lParam & 0xFF0000) >> 16,
(unsigned char *)&lpKeyState,
&lpChar,
0);
if (nRet == 1) {
m_szMain[m_nLastPos] = (char) lpChar;
m_nLastPos ++;
if (m_nLastPos >= MAX_COUNT) {
m_nLastPos = 0;
}
}
Sleep(0);
PostMessage(m_hHwndKey, WM_KEYDOWN, wParam, lParam);
}
}
return 0;
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID) {
Sleep(0);
if (fdwReason == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls(hinstDLL);
}
Sleep(0);
return TRUE;
}
// This is to prevent the CRT from loading, thus making this a smaller
// and faster dll.
extern "C" BOOL __stdcall _DllMainCRTStartup( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
Sleep(0);
return DllMain( hinstDLL, fdwReason, lpvReserved );
}
|
|
|
|
|
A while back I read something telling me that there was a way to call a base class function from the child class; does anyone know how to do this? Thanks!!
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Baseclass::function
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
duh, thanks!
If it's broken, I probably did it
bdiamond
|
|
|
|
|
or simply function() if the child class do not have a function with the same name where the base class declare this function to be virtual...
TOXCCT >>> GEII power
|
|
|
|
|
What's the best way to write HTML code to a file? Is it simply to write the raw tags or are there some libraries around that simply this? Thanks in advance.
- Aaron
|
|
|
|
|
Just write tags like if you were writing some kind of text. save it as you would do with a text file. is the same, but put the .htm extension.
Written by: Rafael Fernández López.
void life ( bool me, bool her )
{
if ( her )
{
me = true ;
}
else
{
me = false ;
} }
|
|
|
|
|
<font style="color:blue;">void </font>life (<font style="color:blue;">bool </font>me, <font style="color:blue;">bool </font>her) {
<font style="color:blue;">if </font>(her) {
me = <font style="color:blue;">true</font>;
}
<font style="color:blue;"></font>else {
me = <font style="color:blue;">false</font>;
}
}
wouldn't you prefer declare me as a bool& or even a bool* instead ?
TOXCCT >>> GEII power
|
|
|
|
|
cool comment !!,
Written by: Rafael Fernández López.
void life ( bool me, bool her )
{
if ( her )
{
me = true ;
}
else
{
me = false ;
} }
|
|
|
|
|
Depend on his religoius philosophy; whether me destructs when leaving life's scope. (That's almost nausiatingly poetic in a nerdy sort of way. Don't think of it as dying, think of it as going out of scope.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
|
As a bool , it consumes 1 byte. As a bool* , it would consume 4 bytes. Correct? If so, future posts would therefore be 300% larger than necessary!
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
ok for the bool* , but that was an expectation for getting me out of the scope. but what about a bool& ?
TOXCCT >>> GEII power
|
|
|
|
|
Michael Dunn told me "Use the CCS_NOPARENTALIGN style".
I've used it but what I win with this is that I can set up the height free, but I am not able to put 30 pixels from left for example. I use this function to call the CToolBarCtrl:
my_tool_bar.Create(WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|CCS_NOPARENTALIGN, CRect(0, 110, 80, 80), this, IDC_MY_TOOL_BAR);
If I set up like this:
my_tool_bar.Create(WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|CCS_NOPARENTALIGN, CRect(30, 110, 80, 80), this, IDC_MY_TOOL_BAR);
The top fails... I don't know what to do...
Please, if you could put me an example of how to create a CToolBarCtrl with no top or bottom alignment into the window... I want to draw it into a CRect from the Window.
Thanks in advance !!!
Written by: Rafael Fernández López.
void life ( bool me, bool her )
{
if ( her )
{
me = true ;
}
else
{
me = false ;
} }
|
|
|
|
|
Well, I solved it:
my_tool_bar.Create(WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|CCS_NOPARENTALIGN|CBRS_NOALIGN|CBRS_FLYBY, CRect(30, 110, 80, 80), this, IDC_MY_TOOL_BAR);
Thanx anyway !!
Written by: Rafael Fernández López.
void life ( bool me, bool her )
{
if ( her )
{
me = true ;
}
else
{
me = false ;
} }
|
|
|
|
|
Hi all! I had a question concerning visual c++ 6.0. I'm coding a card game in Win32 (no MFC) and am trying to fill an edit box on a dialog window dynamically with child controls. What the program does is it queries the current directory for all sound (.wav) files and, for each sound file, inserts three child controls in the edit box on one line. The controls are, from left to right, an edit box for the caption the user wants for this sound file, a play button to listen to the sound, and a second edit box for the name of the sound file.
I'm inserting these into an edit box because, since the sound list is obviously dynamic and of arbitrary length, I'd like to utilize the scroll bar on the edit box. The problem I'm running into is that the edit box is unaware of anything being added to it. I'm calling CreateWindow to add these controls to the edit box, with the handle to the edit box as the parent parameter, and the lines of child controls for the sound files fill up past the depth of the edit box without the scroll bar being activated.
One solution I tried was to insert a newline character into the edit box for each line of controls I added. This solved the scroll bar problem, but when you scroll the edit box the display gets really confused as to what to display (the controls or the "\n").
Any advice is GREATLY appreciated.
Carl Scafidi
|
|
|
|
|
I've never heard of anything other than text being added to an edit control. Do you have an example that shows this?
cscafidi wrote:
The controls are, from left to right, an edit box for the caption the user wants for this sound file, a play button to listen to the sound, and a second edit box for the name of the sound file.
I'm envisioning a list control with two "columns," one for caption and the other for filename. Each of these can be edited in place. A "Play" button would reside next to the list control and would act upon whatever file is currently selected.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
That is a good point, and it need not be an edit box at all. I'm just looking for something like an edit box with scroll controls that I can add dynamic child controls inside of. Do you have any suggestions?
|
|
|
|
|
cscafidi wrote:
Do you have any suggestions?
Nothing additional.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Here is a code snippet:
int xDim = 0;
int width = SOUND_CAPTION_BOX_WIDTH * cxChar;
//SendMessage(hList,EM_SETLINE,int((idx - SND_FILE_LIST_OFFSET)/HWNDS_PER_SOUND),(LPARAM)TEXT("\n"));
SendMessage(hList,LB_INSERTSTRING, 0, (LPARAM)TEXT("\n\n"));
captionRef = CreateWindowEx(
WS_EX_CLIENTEDGE,
"EDIT",
NULL,
//WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | WS_THICKFRAME,
WS_CHILD | WS_VISIBLE | ES_LEFT,
xDim,
yDim,
width,
cyBox,
hList,
(HMENU)idx,
hInstance,
NULL);
SetWindowText(captionRef,caption);
idx++;
numActiveSoundChildWindows++;
xDim += width;
width = SOUND_PLAY_BTN_WIDTH * cxChar;
playBtnRef = CreateWindow(TEXT("button"),
TEXT(" PLAY "),
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
xDim,
yDim,
width,
cyBox,
hList,
(HMENU)idx,
hInstance,
NULL);
idx++;
numActiveSoundChildWindows++;
xDim += width;
width = SOUND_FILE_NAME_BOX_WIDTH * cxChar;
fileNameRef = CreateWindowEx(
WS_EX_CLIENTEDGE,
"EDIT",
NULL,
WS_CHILD | WS_VISIBLE | ES_LEFT,
xDim,
yDim,
width,
cyBox,
hList,
(HMENU)idx,
hInstance,
NULL);
SetWindowText(fileNameRef,fileName);
idx++;
numActiveSoundChildWindows++;
yDim += cyBox;
the 'hList' is the handle to the edit box.
|
|
|
|
|
One word: OwnerDraw
Written by: Rafael Fernández López.
void life ( bool me, bool her )
{
if ( her )
{
me = true ;
}
else
{
me = false ;
} }
|
|
|
|
|
Hi!. i want to overload operator >>. What i've done so far doesn't work. I'm using visual C++ 6.0. When i place my mouse cursor over s, it says int s. It's the same if instead of writing 'std::string s' i write 'string s', even though in the header file i declared 'typedef std::string string;'
<br />
istream &operator>>(istream& stream, XML &x)<br />
{<br />
<br />
std::string s;<br />
std::getline(stream,s);<br />
x.fromString(s);
return stream;<br />
}<br />
This is how i declared inside the class in the header class.
<br />
friend istream &operator>>(istream &stream, XML &x)
this is what i'm including and using in the header file.
<br />
#include <iostream><br />
using std::istream;<br />
using std:stream;<br />
and in main: using namespace std;
my class is called xml
in main i declare:
<br />
xml table;<br />
cin >> table;<br />
thanks!!
|
|
|
|
|
Hi,
First of all, please tick the "Notify me by e-mail if someone answers this message" checkbox on (right below the editbox for entering the post) so that <'s appear correctly.
As for your problem, which is the behavior you observe? Does the program compile and you get weird results, or if it fails to compile what's the error? With a little more info we'll do a better job trying to help you.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
well, it compiles, and i need to load a string (s)from standard input, but as s is thought as an int, nothing gets loaded in s. And i need a string to be loaded in s so i can call the function toString
thanks!
|
|
|
|
|