|
Hi,
for this edit box you have to catch the WM_GETDLGCODE message, telling it that you want DLGC_WANTALLKEYS.
In your WM_KEYUP handler you must look if the user pressed the enter key and than act accordingly. In any other case you should do the default action.
Regards
G. Steudtel
|
|
|
|
|
Hello,
This is my problem:
I have a list box which is used to select a certain item via double-click. This item can then be placed on a map. The problem is, while placing the item, the mousewheel has functionality within the program other than scrolling the list box. I need this mousewheel functionality to work, but once the item in the list box is selected, the focus stays on the list box and the mousewheel will only scroll the list and not do what I want it to do within the main program window.
If I could just move the focus from the list box to some other button, or remove it entirely, (without actually clicking on another list or button) the problem should be solved.
I have tried:
SendMessage(list_box,LBN_KILLFOCUS,0,0);
SendMessage(list_box,WM_KILLFOCUS,0,0);
where list_box is the handle of my list box, but, both of those KILLFOCUS messages are returns rather than messages that can be sent to the handle and processed.
I just need some way to get the focus off of the darned list box...
Thanks for your help,
Kelly
|
|
|
|
|
i was in your case before.
i did lots test, result is: no way to do that.
my solution is: create a Static control (Static has no focus on), then draw strings on the control - it is quite hard because you need to draw scroll-bar also.
when user click the static control, you know which string is selected, then do something according to the string.
but, maybe someone knows easy solution, i hope see it via your post.
includeh10
|
|
|
|
|
Hi,
I once had a similiar problem within a tree control. My solution was to make a boolean variable (bDoubleClicked) which was initially set to false. When the user double clicked an item I just set this variable to true and remembered what he/she choosed.
My actual action was taken on the mouse button up message. By looking if the user had double clicked I performed the task. In any case bDoubleClicked was set to false again.
The problem was that the mouse action was bound to the tree control and not released until the button up message arrived to that control.
I think you should use this method for your problem too.
Hope this helps.
Regards
G. Steudtel
|
|
|
|
|
Thank you for the suggestion, but I think it probably won't work - the problem is, once the mouse clicks onto the list box, that's it, the focus is now on the list box. I need some way to remove the focus from the list box. Regardless of what variables I use to save position and such, once the mouse clicks even once on the list box, that's it, problem activated.
I'd really rather not manually write a list box, I've done that in other portions of the code that involve larger bitmaps and such and it's a pain to always keep track of where they are in relation to the larger window etc, if I'm going to do that I'll just throw in an extra button instead that you're forced to click in order to place the selected items, but that's such a hassle for the user..
I can't imagine that there isn't some way to simply send a message to a window to change or remove focus.. it seems like such a basic function?
Thanks for the suggestions though guys, hopefully there is some way to do this..
Kelly
|
|
|
|
|
After the item in the listbox has been double-clicked, why can't you just call SetFocus() to set the focus on the "map" control?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I didn't realize there was a SetFocus function -
Thank you, that's exactly what I was asking, I just tried it and it works the way I want
|
|
|
|
|
if you have scroll-bar in listbox, i don't think things are so simple, especially need to manage keyboad-input.
visual c++ prompt window (appears if type dot after an object) is an example which doesn't use normal listbox.
includeh10
|
|
|
|
|
A scrollbar does not affect a listbox's ability to set/kill focus.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
if type "command.com" in run-window, a dos-window is lauched.
1. i guess "command.com" should be an execute file, but it doesn't have extension "exe". what is story of file extension of "com", why can it be executed?
2. from process-walker, i can not find "command.com", what is application name of the dos-window?
thx
includeh10
|
|
|
|
|
1. I kept typing different explanations but this'll be easier:
<http: www.faqs.org="" faqs="" msdos-programmer-faq="" part2="" section-9.html="">
2. I have no clue, sorry.
|
|
|
|
|
|
It is the command interpreter. It's been around since the days of DOS. It contains the internal commands such as CD, DIR, CLS, TIME.
Executable files having a .COM extension are usually much smaller and faster than their .EXE counterparts, because of the single code and data segment. With the 16-bit compiler, you could create a .COM file by specifying the tiny memory model. Exe2bin and Debug could also produce them.
http://physics.concordia.ca/~eddy/391/AppC.html
http://www.du.edu/~etuttle/electron/elect59.htm
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Q1 has already been answered more than adequately.
2. NTVDM is used to run any pure 16 bit app, which command.com evidently is.
(And before you ask, that's NT Virtual DOS Machine, hence the name).
Steve S
|
|
|
|
|
I am running in the debugger and find that sPath = "" !!
VERIFY(::GetModuleFileName(AfxGetInstanceHandle(), szBuffer, _MAX_PATH));
sPath = (CString)szBuffer;
sPath = sPath.Left(sPath.ReverseFind('\\'));
What am I doing wrong?
Many thanks,
ns
I just found out that I get the sPath if I run the debug config, butr I have setup my release config to allow debugging too, and when that version runs I get blank!
|
|
|
|
|
For me, these lines
CString filenname;
::GetModuleFileName(AfxGetApp()->m_hInstance, filenname.GetBuffer(MAX_PATH+1), MAX_PATH);
filenname.ReleaseBuffer(); do work.
You might want to check the return-code and GetLastErr() of GetModuleFileName .
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
I hadnt set up the prj correctly for debugging
|
|
|
|
|
Hello!
Use
_pgmptr
or
_wpgmptr
Hope that helps
|
|
|
|
|
Hello,
I have been looking through the CodeProject code and tutorial samples and there is quite a lot of info on how to run another application using the "CreateProcess" and also how to close the run application. Unfortunately I cant find any tutorial on how to send commands to the application(Tutorials in CodeProject just for "Console" control applications). I need to be able to send control commands to another Windows application. The other app can be controlled with just using the "F2, F3," keys etc,.
Thanks in advance to anyone who has any ideas
|
|
|
|
|
through pipe.
see parameters of CreateProcess() function, you can find standard-handler inside, then use CreatePipe() function to establish communications between these handlers (pipe).
includeh10
|
|
|
|
|
Thanks for the answer.
I have now created an application that utilises the createpipe() function.
The application that I am trying to control only uses function keys(F2,F3, etc..). I have tried using Virtual Key Codes (VK_F2, VK_ENTER, etc,..), however this does not seem to have any effect on the application that I am trying to control. Again, does anybody have any ideas?
Thanks again in advance.
|
|
|
|
|
I am alloating and deallocating a byte array as
void OnRecieve
{
if(pBuffer!=NULL)
{
delete []pBuffer;
pBuffer=NULL
}
pBuffer=new BYTE[5000];
}
i get the raw picture data from socket , allocate and dealloate memory as .
This code works fine for quite a long time , but may be after 3 , 4 hr.(So this code works fine for thousands executions )
I get the assertion while deleting this array.
in DBGHEAP.C File.
What might have the cause , Is there some other safer way to do this.
No Worries!
|
|
|
|
|
Could be a few things, the most likely is that you are writing past the end of one of your buffers at some point(probably by very few bytes,most likely one). You should:
- Check your code thoroughly where you write to the heap(allocated by new or malloc)
- Use memory checksumming to home in on the error, there is a CP article on this
- Evaluate a memory leak/overrun detection tool, such as boundschecker - lots of peeps can't live without them. Especialy if they do maintainence programming
5000 bytes is small enough to go on the stack really, and your program will fail in a much more entertaining way if that buffer is the culprit.
Ryan
|
|
|
|
|
It was on the CheckByte statements.in DBGHEAP.C
No Worries!
|
|
|
|
|
If you know you are always going to be allocating 5000 bytes, use Ryan's suggestion and use the stack. Dynamic allocation should be limited to cases where the amount needed is unknown until run-time.
Atif Mushtaq wrote:
I get the assertion while deleting this array.
in DBGHEAP.C File.
What line?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|