|
Hmmmm!
1) Open file.
2) Get size of file.
3) Allocate enough memory to hold entire file.
4) Read file into buffer.
Of cource this only applies if file size if smaller than the maximum buffer size that you can allocate. Under Win32, you can allocate very very large buffers.
INTP
|
|
|
|
|
Yep, that's exactly what I did, just making sure it's the fastest way.
Thanks for the help.
|
|
|
|
|
Sir,
THis is my first application with hooks.
I amtrying to register WH_KEYBOARD hook for my app so that when ever I tried to make Caps tab on this will set to off.
So I placed a gloabl variable of HHOKDATA and a glabal proc -KeyboardProc.
I placed these globally in CMainFrm.cpp
I registered this hook using using SetWindowsHookEx and called in OnCreate of CMainfrm.cpp.
But this is not getting called and let me know what to do so that this hook should call .
Should I map the events ????
But hooks will getcalled only before the event is passed to WndProc?
Pls correct me if I am wrong.
Where I am going wrong?
|
|
|
|
|
blacktiger007 wrote:
I registered this hook using using SetWindowsHookEx and called in OnCreate of CMainfrm.cpp.
But this is not getting called and let me know what to do so that this hook should call .
What is not being called? SetWindowsHookEx or the hook you are trying to install?
blacktiger007 wrote:
But hooks will getcalled only before the event is passed to WndProc?
Hooks are called before the window message is delivered to a message pump.
If you are trying to install a global hook, please note the section in the MSDN docs: The global hooks are a shared resource, and installing one affects all applications in the same desktop as the calling thread. All global hook functions must be in libraries. Global hooks should be restricted to special-purpose applications or to use as a development aid during application debugging. Libraries that no longer need a hook should remove its hook procedure.
Are you installing a global hook? If so, do you really need the global hook? If you are installing a global hook and you really need it, there's this[^] article.
--
Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr.
Welle: Erdball - F104-G Starfighter
|
|
|
|
|
I called a global hook and wrote the code in CMainFrm.cpp fie and called SetWindowsHookEx in OnCreate of CMainFrm.
I wrote the code KeyboardProc here.
When I tried to debug it ,The actual KeyboardProc deined in this file is not geting called.
Pls solve this as I will extend this app using DLLs later.
|
|
|
|
|
I'll recite the MSDN docs again: All global hook functions must be in libraries.
Those are the rules. Period.
--
Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr.
Welle: Erdball - F104-G Starfighter
|
|
|
|
|
sir why not use a dll to set the hooks and put the callback function there.
The virtual keycodes for capslock and tab are:
VK_CAPITAL 14(value hexadecimal) CAPS LOCK key
VK_TAB 09(value hexadecimal) TAB key
So in your callback function you'll have to monitor whenever these key are pressed and when they are pressed instead of returning 0 (as success) return 1 (as error).
And there you are
gabby
|
|
|
|
|
Sir,
Thx for the response.
This is the code for a global hook which I defined in MainFrm.cpp
But even without using a dll this should get fired after registering the hook by calling SetWindowsHookEx in OnCreate of CMainFrm
Pls correct me if I m wrong .
LRESULT CALLBACK KeyboardProc(int code,WPARAM w,LPARAM l)
{
if (code < 0)
return CallNextHookEx(m_hookData,code,w,l);
unsigned char state[256];
if( w == VK_CAPITAL)
{
GetKeyboardState(state);
if(state[VK_CAPITAL] == 1)
{
state[VK_CAPITAL] =0;
SetKeyboardState(state);
}
}
return CallNextHookEx(m_hookData,code,w,l);
}
|
|
|
|
|
first ,your must read this article and learn his technology.
http://www.codetools.com/internet/winsockiocp.asp?df=100&forumid=2079&select=861727
because i used his code in my project,the server-exe file works fine in win2000 server os,but under windows xp or windows 2003 server os ,the server-exe file works fail! i used port 5000 in the CIOCPServer intialize function. under 2000 server os,when the server-exe file execute ,use system command netstat -a ,i can see port 5000 is opened.but when the server-exe file execute in windows xp or windows 2003 server os, use the system command netstat -a ,there isn't port 5000.client-exe is failed during connecting. i expect for your help.thanks a lot.
|
|
|
|
|
It is not easy to debug this IOCP issue as you are using some arbitrary IOCP I/O wrapper class. Is the XP system configured correctly?
Kuphryn
|
|
|
|
|
Is the wsaasynSelct() function limited under windows xp or windows 2003? the configuration is default of system. i
don't limit any port.
|
|
|
|
|
I have created a few procedures in assembly that I want to be C++ callable. I also want to be able to give arguments.
I am using Masm as my assembler and Visual C++ as my compiler.
I already know that I need to append a _ to my functions. I also seem to remember poping things off the stack for parameters, but I don't know for sure.
An example is a procedure:
_Out
I want it to take a byte as one parameter and a word as the next, and then I want to be able to call it from a C++ program that it is somehow linked to. (I don't know how to do that either)
How would I go about doing this?
Thanks
|
|
|
|
|
Is bringing your assembler code to a CPP file an option ?
here's an example, even with a return value
word Out(char p1, word p2)
{
word param;
_asm
{
mov ah, p1
mov cx, p2
..
..
mov param, cx
}
return param;
};
Hope it helps,
DarkByte
|
|
|
|
|
I'm working on a Win32 (actually, Qt) app, and would like to use the alt key to modify some keyboard/mouse buttons. It's working great, except that pressing the alt key moves the keyboard focus to the menu (like it normally should). How can I disable/avoid that? Most importantly, is there a simple solution, without having to manually process messages?
Thanks!
|
|
|
|
|
I don't think there's an easy solution. Especially not so with Qt, as it probably hides the message pump from you.
I tried this in MFC:
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
if((pMsg->message == WM_SYSKEYDOWN || pMsg->message == WM_SYSKEYUP)
&& pMsg->wParam == VK_MENU) {
DoMything();
return TRUE;
}
return CFrameWnd::PreTranslateMessage(pMsg);
} and it worked fairly well I believe. It didn't mess with the accelerators (ALT-F for File Menu, ALT-F4 for close application, etc), but it allowed me to do whatever I want to with the ALT-button. In this case I'm just filtering it out. If it's possible to implement a PreTranslateMessage() function in Qt, it's not a hard problem.
Good luck.
--
Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr.
Welle: Erdball - F104-G Starfighter
|
|
|
|
|
Thanks! Qt does have its own version of PreTranslateMessage, and I implemented it like so:
<br />
if(pMsg->message == WM_SYSKEYUP && pMsg->wParam == VK_MENU && bIgnoreNextMenuKey)<br />
return true;<br />
|
|
|
|
|
hi everyone.. i'd like to ask a very² simple question.. i guess it's too simple to post it here
say i have this equation.. c=a+b..
i want to make an interface which has 3 edit boxes and a button. two boxes for the user to input a and b and another box is for the answer (which is the c).. with the press of the button, i can get the answer in the answer box. my question is, how to pass the values in the two input boxes (a & b)to the button and pass the answer to the answer box (c)?
thanx for your guidance and time..
~wilDcat~
|
|
|
|
|
I've been using C# for a number of months, so I'm a bit rusty on Visual C++, but I'll try to help you out.
You can get the values in a number of ways, but I have always found the following to be the easiest:
CString A_Value, B_Value, C_Value;<br />
EditBoxA.GetWindowText( A_Value );<br />
EditBoxB.GetWindowText( B_Value );<br />
<br />
int TempA = 0;<br />
for ( int x = 0; x < A_Value.GetLength(); x++ )<br />
TempA = isdigit(CurrentSelection[x])?TempA*10+(CurrentSelection[x] -48):TempA;<br />
<br />
int TempB = 0;<br />
for ( int x = 0; x < B_Value.GetLength(); x++ )<br />
TempB = isdigit(CurrentSelection[x])?TempB*10+(CurrentSelection[x] -48):TempB;<br />
<br />
CValue.Format( "%d", TempA+TempB );<br />
EditBoxC.SetWindowText( CValue );
The Above should work...again, I have used C++ for a while, there may be an easier method of parsing the strings into integer values, but those loops will work (although they don't work for doubles, only integers...you'll have to figure that out on your own.)
Good luck, I hope I at least gave you an idea of what you can do.
-Doug
|
|
|
|
|
thanx very much.. at least u give me something to work on.. i'm new to vc but i'll try it out.. thanks very much!
~wilDcat~
|
|
|
|
|
You can use strtol() , strtoul() , or strtod() (among others) to convert strings to numbers.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I need a GetClusterSize function so that I can work out how much space a file will occupy on a particular disk.
The WIN32 function GetDiskFreeSpace should do this but doesn't work for large disks. The replacement, GetDiskFreeSpaceEx, doesn't have this capability.
So what do I do?
Target is any WIN32, VC++ 6, MFC.
|
|
|
|
|
Hello,
is there a way to make a HFONT out of a TTF file? without installing the font? (I need a font for my project, but I don't want to mess up with the installation - and I also want it to be working when the user reinstalls the OS and keeps the app)
thanks a lot
|
|
|
|
|
try and take a look at AddFontFile(...) which maps to GdipPrivateAddFontFile(...) in GDI+.
Do a search on MSDN for the functions i mentioned or try "Font Functions" in the search box.
DarkByte
|
|
|
|
|
How can I rename an NT user using the ADSI(Active Directory Service Interfaces)? The IADs::SetInfo method can only change user's fullname not rename a user.
|
|
|
|
|
hi all!
Mu problem is to draw the scrolbars on my application.
It is realized with mfc and it is MDI.
I wanto to draw the scrollbars on the child window when I load an image larger than the window.
I try to edit code in the ChilFrm.cpp file and i wrote this:
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE;
cs.style |= WS_VSCROLL | WS_HSCROLL;
return TRUE;
}
In this way the two scrollbar appear, but they don't do anything.
can you help me?
thks a sorry for my english
|
|
|
|