|
AFAIK CreateFile has no 'append' option: you have to go to the end of the file
(via SetFilePointer ) after opening it correctly for append (i.e. depending on your needs, with OPEN_ALWAYS or OPEN_EXISTING as dwCreationDisposition parameter) and start writing there.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Do you need to CFile::Seek?
|
|
|
|
|
Yes, he does
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
I think yes,Hi Nelek how are you.
|
|
|
|
|
Fine thanks, a bit away of VC++ but trying not to forget :P I changed job and city.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
I guess maybe you forgot me.
|
|
|
|
|
No, I just forgot to check messages contents from forums notices , just saved all and now that I had time... I have made clean up answering and keeping the ones I consider to be kept.
It was a long time without coming to forums :P
I will get more often so... see you in the posts
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
I create a list box as a popup window with parent as NONE and display it below a combo box. (This is imitation of intellisearch IE or IAutoComplete in WTL)
The creation of the listbox looks like this
<br />
CMyComboBox::CreateListbox() {<br />
BOOL bRet = _list.CreateEx(0, <br />
_T("ComboLBox"), <br />
_T(""), <br />
WS_POPUP | WS_VISIBLE | WS_BORDER | WS_VSCROLL <br />
| LBS_NOTIFY,<br />
clientRect.left, clientRect.top, <br />
clientRect.Width(), clientRect.Height(), <br />
this->GetSafeHwnd(),
NULL, <br />
NULL);<br />
}<br />
I display this listbox when user starts typing some text in the combobox. I add the filtered strings as per the text to this listbox.
There are two problems
1. I am trapping all the messages send to Listbox in its windowproc.
I find that the first time I display this listbox, I am able to see LBN_SELCHANGE (or other listbox specific messages) being trapped in Windowproc. But they are sent only once. The next time when I try to change any selection, LBN_SELCHANGE is not sent/trapped (I don't know where this message goes).
Although the basic messages - LBUTTON_DOWN/UP, KEY_DOWN/UP are being sent to the Listbox.
I intend to write something like below, but LBN_SELCHANGE is caught only once.
<br />
LRESULT CAutoCompListBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)<br />
{<br />
<br />
switch(message) {<br />
case LBN_SELCHANGE: {<br />
}break; <br />
Does the question make sense? or its too vague?
2. I need to find a decent way to send the listbox messages to the combobox. Since the combobox is not at all related to Listbox here, I may have to resort to registering a callback in the Listbox to handle the messages. Is there any other way to handle the messages?
Thanks first of all for reading the question.
Many many thanks if you got some answers
Evil triumphs when good people sit quiet...
|
|
|
|
|
misha_grewal wrote: LRESULT CAutoCompListBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) {
case LBN_SELCHANGE: {
[LBN_SELCHANGE^] is a notification message sent through WM_COMMAND message. Correct it and check, later we discuss for the decent way.
misha_grewal wrote: But they are sent only once
Actually you caught the WM_CREATE ( == 1 == LBN_SELCHANGE) message which is send only once.
modified on Monday, April 28, 2008 10:35 AM
|
|
|
|
|
Thanks a ton..
Rajkumar R wrote: Actually you caught the WM_CREATE ( == 1 == LBN_SELCHANGE) message which is send only once.
Yes, I think thats what I was catching..
The windowproc of the list box is getting all the WM messages like WM_KEYDOWN or LBUTTONUP. But a message like LBN_SELCHANGE is never caught in windowproc. why is it so?
WM_COMMAND is sent to a parent of a window and the wparam has the message id. In this case, the list box doesn't have any parent as such, so you never receive WM_COMMAND messages
Evil triumphs when good people sit quiet...
|
|
|
|
|
misha_grewal wrote: the list box doesn't have any parent as such
ComboBox is the parent which you already set in CreateEx and get Notified since you set WM_NOTIFY, Any way since you are using MFC use ON_CONTROL_REFLECT to get the notification to the ListBox itself, Add handler to ListBox class to allow wizard to put ON_CONTROL_REFLECT macros.
modified on Tuesday, April 29, 2008 5:00 AM
|
|
|
|
|
can anybody tell me where a static variable get stored in memory
Thanks in advance
|
|
|
|
|
The static variables are stored in the .data section of the corresponding module.
|
|
|
|
|
Hi at all,
is there a possibility to look which code is behind the function ::SetFocus(m_hWndFocus) ?
Because even i set the m_hWndFocus to a given control, Focus will not set on this control,
it changes to another control on the view ...
Big thanks for help
Greetings
|
|
|
|
|
I don't think you can see code of WinAPI functions. In any case I can assure you that there is no bug in that function and looking at code of SetFocus is not going to help you fix your problem. Maybe if you share how exactly are you using SetFocus then someone can help you find the problem.
-Saurabh
|
|
|
|
|
Many thanks for you help!
Sure, in ::SetFocus isn't a bug, but maybe i can see why it doesn't accept my control.
I have the following action:
A View into a frame has some textboxes and a "self-created*" Grid.
If i hit a button a thread searches the elements and displayes all into the Grid.
If i hit ENTER on the Grid, i post a message wich creates a new View and switches
the view of the frame with this new view.
In the second view i have the possibility to hit ESCAPE and re-switch the first view on the frame.
So i went back to the first view, but the focus isn't no more on the Grid (where i left) but it's on
a textbox...
During i switch the view of the frame i call also a NewView->SetFocus() to set the Focus on the actual view of the frame...
If i set the m_hWndFocus manually on the Grids-Handler the ::SetFocus(m_hWndFocus) don't affect it
and sets the focus anyway on the textbox.
Big thanks for any help
* = not with the ressource designer, but with "new" and "Create(...)"
Edit:
OK, i find the bad code ...
It was a part of code which is running good for (A) and goes wrong with (B)
Thanks anyway
modified on Monday, April 28, 2008 9:51 AM
|
|
|
|
|
can we find whether a window belongs to particular application?
I want to find through code but not through spy++.
Actually I have dc of wiandow which I am converting it to handle now I want to know whether it belongs to our application or not...
Expecting favourable reply.
|
|
|
|
|
|
GetWindowModuleFileName(..) is not supported in winxp showing error even after incuding windows.h or winuser.h
are there any similar API's?
|
|
|
|
|
Actually it should be supported. What error do you get?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
'GetWindowModuleFileName' : undeclared identifier
|
|
|
|
|
On my system (I'm using VS 2005 ) GetWindowModuleFileName declaration is in winuser.h .
Furthermore, the function properly works on my XP OS .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
|
Super Hornet wrote: I am using Visual Studio 6.0
Then you probably need to get an updated Platform SDK.
Super Hornet wrote: I have found this message in MSDN: It doesn't work for other processeses on Windows 2000, XP and Vista.
http://msdn2.microsoft.com/en-us/library/ms633517(VS.85).aspx[^]
Well that maybe true, but it has nothing to do with the error you reported.
BTW some info about GetWindowModuleFileName failure on XP here [^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Okay my bad this function work only if the calling process owns the window. using GetWindowThreadProcessId you can get both thread id and process id. Once you have process id then you can simple compare with your process id to check if window belongs to your application.
-Saurabh
|
|
|
|