|
Hello,
Please help me with CListCtrl arrow key navigation - I have my own listctrl class, but when I use the arrow keys to scroll up and down though it, the current item is not identified correctly (I use UINT whichItem=GetNextItem(-1,LVNI_SELECTED) ). It is updated one step behind, i.e. I'm on item 0, I press the down arrow, the whichItem is still 0, I press the down arrow again and then it becomes 1. Maybe I need to implement a keyboard handler in my derived class or something?
Thanks in advance,
Dennis
MCP, MCSD
|
|
|
|
|
Where are you trying to retrieve the current item? If it's from a state-changing notification, then the previous item may yet be selected.
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
I'm trying to get this in the OnLvnKeydown by responding to this:
<br />
ON_NOTIFY(LVN_KEYDOWN, IDC_LIST, OnLvnKeydown)<br />
(and in my previous code I of course meant cList.GetNextItem(), instead of GetNextItem() - I'm not trying to get this from inside my derived class).
MCP, MCSD
|
|
|
|
|
Ok, that makes sense now. Unless you specifically need to pay mind to keyboard selection while excluding all other forms, it would be easier for you to use the notification LVN_ITEMCHANGED and watch for changes to the selection state:
void CMyWin::OnItemchangedListCtrl(NMHDR* pNMHDR, LRESULT* pResult)
{
NMLISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
*pResult = 0;
if ( pNMListView->iItem < 0 )
return;
if ( (pNMListView->uOldState & LVIS_SELECTED)
&& !(pNMListView->uNewState & LVIS_SELECTED) )
{
}
else if ( !(pNMListView->uOldState & LVIS_SELECTED)
&& (pNMListView->uNewState & LVIS_SELECTED) )
{
}
}
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
Yeah, that code works, thanks. I was watching for the OnItemChanged in another list I had, but that was to process checkmarks, for some reason I didn't think about watching for selection as well. Could've saved me some time But I really don't understand why it doesn't process the OnKeyDown correctly.
MCP, MCSD
|
|
|
|
|
dennisV wrote:
But I really don't understand why it doesn't process the OnKeyDown correctly.
Most likely it sends the notification *before* it does it's own processing, thus the selection doesn't get changed until after your notification handler returns. Couldn't say why they did it that way, but you're usually better off not using it for selection changes anyway, as it'll ignore the mouse.
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
Hello all,
I have a dialog app that sits in the tray and pops up a dialog to remind the user of something every hour. It obviously does no good if a screensaver is running. I did some searching around and found ways of interrupting it and found some good stuff from Bob Moore's site:
void CMCAlarmDlg::KillScreenSaver()
{
HWND hwnd;
if (hwnd = ::FindWindow ("WindowsScreenSaverClass", NULL))
{
::PostMessage(hwnd, WM_CLOSE, 0, 0);
}
else
{
if (hwnd = ::FindWindow ("Default Screen Saver", NULL))
{
::PostMessage(hwnd, WM_CLOSE, 0, 0);
}
}
}
This does work on Win2K, but not on NT 4. I've tried several other things (tried this one too: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q140723)but haven't had any success. Several people have mentioned how unreliable FindWindow() can be.
My question is, is there another way to interrupt the screensaver by a keyboard or a mouse? Bob Moore mentions doing this himself with hooks, but doesn't elaborate. Hooks are a bit beyond my beginners skill level anyway. Or has anyone had good luck with something that works across the board (9x, NT, 2K, XP)
Ideas?
Thank you all (again) in advance.
Matt
|
|
|
|
|
Hello,
There is a nice little function which simulates a mouse event (by sending a mouse message to the active window) called 'mouse_event'. Sending a MOUSE_MOVE message to a screen saver would make it kill itself, because it automatically closes itself wheenever there is any mouse activity.
MSDN said that on Windows NT and 2000, 'mouse_event' has been superseded by 'SendInput', so here is the information for both functions (you might want to check the OS, so you can use the correct function):
'mouse_event':
VOID mouse_event(
DWORD dwFlags,
DWORD dx,
DWORD dy,
DWORD dwData,
ULONG_PTR dwExtraInfo
}
dwFlags: look up this function on MSDN to see all the options; the one you want is MOUSEEVENTF_MOVE, to simulate a mouse movement. MOUSEEVENTF_ABSOLUTE can be combined with this flag (e.g. MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE) to let you specify absolute coordinates in 'dx' and 'dy'.
dx: if MOUSEEVENTF_ABSOLUTE is set in the firest parameter, this specifies the absolute position along the 'x' axis of the mouse. Othwerwise, this specifies how many points you want to move along the 'x' axis.
dy: same as 'dx' only for the 'y' axis
dwData: this specifies mouse wheel movement; you don't need to worry about this, because you won't be using the MOUSEEVENTF_WHEEL option. Just set it to 0 or NULL.
dwExtraInfo: used to send a value with the message. Set this to 0 or NULL for your purposes.
'SetInput':
UINT SetInput(
UINT nInputs,
LPINPUT pInputs,
int cbSize
}
nInputs: number of input events (mouse events) that you want to send
pInputs: a pointer to an array of INPUT structures. An input structure looks like this:
typedef struct tagINPUT {
DWORD type;
union {
MOUSEINPUT mi;
KEYBDINPUT ki;
HARDWAREINPUT hi;
};
} INPUT, *PINPUT;
For your purposes, you want to use the 'mi' variable, so you would set 'type' equal to INPUT_MOUSE. The MOUSEINPUT structure contains almost identical variables to the 'mouse_event' function. To send a movement command, you would set the 'dwFlags' variable of the structure to: MOUSEEVENTF_MOVE or MOUSEEVENTF_ABSOLUTE, and the 'dx' and 'dy' variables to the coordinates of your choice. Every other variable can be filled with 0 or NULL.
cbSize: size of the structure. Set this equal to sizeof(INPUT) , which gives you the size, in bytes, of an INPUT structure.
Here are sample calls to each function:
'mouse_event' sample call:
mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE, 0, 0, NULL, NULL);
'SetInput' sample call:
INPUT myInput;
myInput.type = INPUT_MOUSE;
MOUSEINPUT mouseInput;
mouseInput.dwFlags = MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE;
mouseInput.dx = 0;
mouseInput.dy = 0;
mouseInput.mouseData = NULL;
mouseInput.time = 0;
mouseInput.dwExtraInfo = NULL;
myInput.mi = mouseInput;
SetInput(1, &myInput, sizeof(INPUT));
SetInput is a pain to call, and since you are only moving the mouse, you could get away with calling mouse_event across all platforms.
Hope that helps you out!
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
Excellent! This looks exactly like what I need. I'll try this out and let you know.
Thanks Alexander for your time.
Matt
|
|
|
|
|
Great! Let me know if it works out for you!
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
Hello Alexander,
Well after implementing your idea, I've come to find out that it works great on Win2k, but not on NT. I didn't have the opportunity to test it on XP, but I've since found a newsgroup posting that suggests that it does (his code and sugguestions were very similar).
I ended up using this: http://www.mooremvp.freeserve.co.uk/Win32/framed_tip022.htm; and modified it a bit 'til it started working. Like I said, yours worked great for 2k (and probably XP). I've stored your reply for future use if needed. You might test it on NT and see what your results are. If you find something, let me know since it's alot easier than doing it like the link above shows.
Can't thank you enough for your help. Your instructions were comprehensive and easy to follow.
Thanks again,
Matt
|
|
|
|
|
Hi,
I'm writing a ISAPI program for a company project. The project requires that I don't use a database to save the user input. Instead I want to write the user data into a disk file on the server using CFile, is this possible?? I tried using CFile and writing it into a directory on the server that has write permissions, however all I get is a Exception in filecore.h.
Thanks for your help!!
|
|
|
|
|
Akula wrote:
Instead I want to write the user data into a disk file on the server using CFile, is this possible??
Yes.
Jason Henderson quasi-homepage articles "Like it or not, I'm right!"
|
|
|
|
|
Here is the code I used
CFile myFile;
myFile.Open("Data//MyFile.txt",CFile::modeCreate || CFile::modeWrite);
myFile.Write((void*)pCtxt,sizeof(*pCtxt));
myFile.Close();
I also tried that like this
CFile myFile;
myFile.Open("MyFile.txt",CFile::modeCreate || CFile::modeWrite);
myFile.Write((void*)pCtxt,sizeof(*pCtxt));
myFile.Close();
|
|
|
|
|
Akula wrote:
"Data//MyFile.txt"
Try using the full path.
Also, it would be a good idea if you would check the return value of Open before you Write and Close. It would also be helpful to do a GetLastError if it fails so you would know why.
Jason Henderson quasi-homepage articles "Like it or not, I'm right!"
|
|
|
|
|
Akula wrote:
I tried using CFile and writing it into a directory on the server that has write permissions
Are you sure that directory has write permissions for the account that inetinfo is running on (usually IUSR_something) ?
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
I'm positive I just doubled checked.
|
|
|
|
|
|
I'm sure it's not the write permissions, I just ran a CGI bin program that wrote to the server(in the same directories) just fine.
|
|
|
|
|
|
does anyone know of an FTP add-in for visual studio, more specifically visual c++?
i'm currently programming in java, on a unix platform, but use my PC for all coding, then ftp the files to the unix box for compile/run.
anyway, I've been using slickEdit, and it's a piece of sh**
in my opinion. it's lacking almost everything that i've grown accustomed to in vc++.
the only thing that it's got going for it, is an ftp client that allows for ease of file transfer from my pc to the unix box, and back again.
is there an add-in, or some tool that I could make part of the vc++ IDE ?
Certainly I could ftp it via command line, but what a pain.
thoughts?
|
|
|
|
|
FTP it using command line, but as an post build step, so it is done automatically for you.
Concussus surgo.
When struck I rise.
|
|
|
|
|
actually, it's a java project, so I'm not doing any building.
I'm basically looking for something that would, when I save the file, FTP it back.
In SlickEdit, they've got a "file-explorer" like view on the left, and you double click the desired file to open it/ftp it to you, then when you save, it's ftp-ed back to the server.
for building, I've got a telnet session open where I simple
"javac" my files.
I don't imagine I'm the only one that wants to use VC's IDE for just about everything.
thoughts?
Paul
|
|
|
|
|
Nope, only that UltraEdit has nice syntax highligthing and some useful features, including FTP, but never saw anything like you said.
Concussus surgo.
When struck I rise.
|
|
|
|
|
What OS are you coding on? (Win2k or WinXP)
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|