|
jhwurmbach wrote:
In fact, RegisterWindowMessage() is the most desireable version of a private message.
Is that because they're guaranteed to be unique to the string used to identify them and therefore you get less potential conflicts?
Are you saying that there is no situation where a RegisterWindowsMessage is less preferable to a WM_USER + i one?
Cheers, Alex.
|
|
|
|
|
You should never use WM_USER+i , because some i are already used by some (newer) windows controls. You get almost undebuggable errors when you are reacting to messages that are not meant for you.
Use WM_APP+i , this is guaranteed not to be used by Windows internally.
You then only have conflicts with controls from other sources (commertial or third party).
Use of RegisterWindowsMessage() avoids all this at no cost.
No, I cant think of a situation where WM_USER is more preferable than RegisterWindowsMessage() .
|
|
|
|
|
If you are making your own control, WM_USER+x is fine.
However, for application level messages, I have to agree that RWM is better.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
You should use RegisterWindowMessage only. Read this[^] for details!
Best regards,
Alexandru Savescu
|
|
|
|
|
Alexandru Savescu wrote:
You should use RegisterWindowMessage only. Read this[^] for details!
This (and that on message management) was one of the articles I was referring to in my originaly post. I was wondering why MSDN says that you should only use RegisterWindowsMessage() for inter-process messages and WM_USER + i for the others.
I suppose it's just like a lot of the other bits in MSDN - looks absolutely fine until you talk to other people about it...;)
|
|
|
|
|
What I need to do is compare a series of strings (actually filenames) and find potential duplicates. The strings, however, are unlikely to contain literal duplicates so what I need to do is find similar strings. Has anyone ever had experience of this before?
Cheers
James
|
|
|
|
|
Yes, this is a common need in credit applications (find names mistyped). In your case, I suggest the Levenshtein String (or Edit) Distance algorithm for this. You can find tons of implementations in C++ on google.
lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik
|
|
|
|
|
Thanks for that Daniel. I took a look at it and that solves part of my problem. The other part of the problem is that I need to find duplicates based on whether a string has some elements of another.For example, I would want to match the following filenames
c:\Music\Albums\Vines\01 - Highly Evolved.mp3
c:\Music\Singles\The Vines - Highly Evolved.mp3
f:\Stuff\Vines - Highly Evolved.wma
Do you know if there is a standard way to do this? I don't think there is but I just wanted to make sure.
Cheers
James
|
|
|
|
|
If you are really into informatics as a science, maybe some algorithms from bioinformatics can help you. Finding substring in one another and computing similarity-distance is quite common in DNA-sequence handling.
You will find more stuff about that in the net than you are able to read in the entire rest of your life.
|
|
|
|
|
Hi:
I meet a problem, it has puzzled me for a long time. I create a COM dll which support MFC, several
methods was exposured. The implement code of two methods was shown as follow:
STDMETHODIMP CMyComObj::OnConfiguration(long iReserved, BOOL *pbSuccess)<br />
{<br />
AFX_MANAGE_STATE(AfxGetStaticModuleState())<br />
<br />
CMyCfgDlg dlg;<br />
int rtn = dlg.DoModal();<br />
*pbSuccess = (rtn == IDOK) ? TRUE : FALSE;<br />
return S_OK;<br />
}<br />
<br />
STDMETHODIMP CMyComObj::ShowUIFace(long hParentWnd)<br />
{<br />
AFX_MANAGE_STATE(AfxGetStaticModuleState())<br />
<br />
pdlg = new CMyUIDlg();<br />
if(pdlg != NULL)<br />
{<br />
pdlg->Create(ID_MYUIDLG,CWnd::Fromhandle((HWND)hParentWnd));
}<br />
*pbSuccess = (rtn == IDOK) ? TRUE : FALSE;<br />
return S_OK;<br />
}<br />
The problem is in the first method call, the dialog shown normal and I can use TAB switch focus from
one control to another control. When I use the second method call, the dialog shown normal but can't
use TAB to switch focus(It does not take effect). The reason is virtual function PreTranslateMessage
was not be processed, What's wrong? Please help me!!!
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
nothing wrong.
in MFC, PreTranslateMessage is only function which handles all of messages (similar to windows in Win32).
for other function (i.e. WindowProcess), MFC filters (bad design, i think) and adds many messages.
typically, it filters TAB, arrow key: up,left,right,down.
if TAB doesn't work, normally arrow keys don't work eithr
includeh10
|
|
|
|
|
Thanks,but how to solve this problem?
I want "PreTranslateMessage" be called normally.
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
Hello,
I want to use the SELECT some recordsets in an XML format (using the SQL Server 2000 features). I am using Carlos Antollini classes that wrap the ADO database clases. I am declaring a CADORecordset object, open it and use GetFieldValue (0, var) , where var is a _variant_t object.
Its type is VT_ARRAY | VT_UI1 (this means an array of bytes, rights?). The parray member looks like this:
cDims = 0x0001;
fFeatures = 0x0080;
cbElements = 0x00000001;
cLocks = 0x0;
pvData = 0xsmth;
Dumping my array of bytes into a file looks awful. However, looking at the code the array looks like an array of BSTRs, but is not the XML encoded data I am expecting.
Can anyone help?
Thanks.
Best regards,
Alexandru Savescu
|
|
|
|
|
I have a dialog with a list view control (CListCtrl ).
So, I want that the list view control never lost the selection! It should be allways one item selected!
It should be also be one item selected if the list view control lost the focus! When I set the LVS_SHOWSELALWAYS flag only draws a gray background on the item, I want that there is allways one item selected in blue (like in the CListBox ).
I tried to modify the NM_LISTVIEW struct during the OnItemchangingList1 function (= LVN_ITEMCHANGING ), but I have no idea how to change this struct.
Can anyone help me?
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
You can use the owner dran features. It mean that you can draw somethings yourself. Read the MSDN.
|
|
|
|
|
The way I do what you are asking is to use Owner Draw.
Here's how to do it.
1. Set the window style of the list control in your dialog resource to Owner Draw Fixed
2. Derive your own list control from CListCtrl
3. Override void CYourNewCtrl::DrawItem(LPDRAWITEMSTRUCT lpDIS)
Example
void CYourNewCtrl::DrawItem(LPDRAWITEMSTRUCT lpDIS) <br />
{<br />
CDC dc;<br />
dc.Attach(lpDIS->hDC);<br />
int nCol;<br />
LVCOLUMN lvc;<br />
lvc.mask = LVCF_WIDTH|LVCF_FMT;<br />
<br />
CRect rc = lpDIS->rcItem;<br />
<br />
COLORREF m_crFG = GetSysColor(COLOR_WINDOWTEXT);<br />
COLORREF m_crBG = GetSysColor(COLOR_WINDOW);<br />
COLORREF m_crSelBG = GetSysColor(COLOR_HIGHLIGHT);<br />
COLORREF m_crSelFG = GetSysColor(COLOR_HIGHLIGHTTEXT);<br />
<br />
BOOL bSelected = GetItemState(lpDIS->itemID,LVIS_SELECTED);<br />
BOOL bFocused = GetListCtrl().GetItemState(lpDIS->itemID,LVIS_FOCUSED);<br />
<br />
int nOldMode = dc.SetBkMode(TRANSPARENT);<br />
<br />
dc.FillSolidRect(rc, bSelected?m_crSelBG:m_crBG);<br />
<br />
COLORREF crText = (bSelected?m_crSelFG:m_crFG);<br />
<br />
dc.SetTextColor(crText);<br />
<br />
<br />
<br />
dc.SetBkMode(nOldMode);<br />
<br />
dc.Detach();<br />
}<br />
Kind regards,
Tim
|
|
|
|
|
Thanks! I will try it!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Dear Friends,
Good Day Everybody...
I built an application (SDI)and i need to open a window or a dialog (more than one at a time) to view some data.
the data will differ from one window to another, thats why i need to open more that one window how i can do this Modal dialogs cant do this plz help.
Best Regards,
zakarni
|
|
|
|
|
Modeless dialogs should do the trick. Store your dialog as a member variable, and then call ( from memory ) Create instead od DoModal, and ShowWindow. I use pointers, and do this in the dialogs constructor
if (Create(IDD, pParent)) ShowWindow(SW_SHOW);
That's from memory, but it's something like that.
Of course if you use pointers, make sure to set them to NULL when you delete them, and call DestroyWindow on them first. Or just call ShowWindow(SW_HIDE); to hide them. I use ::IsWindowVisible((m_pDialog); to see if a window exists and is visible.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
But better style were views.
|
|
|
|
|
i have two views in the program one uses the treeview and the second uses a listview now each item in the list view should be opened in a seperated window.
this is what i was asking i might open moore than one item from the list how can i do this.
thanks,
Best Regards,
Zakarni
|
|
|
|
|
Hello Friends,
I have a very intresting question .
The problem is that i have written an application(.exe) it uses a .dll file i.e few functionality are provided in the dll file . as the file is used it is loaded dynamically now the problem is that i want to change this dll without unloading the application is this possible??? i have done some changes in the dll so without unloading the application can i unload the dll and again reload it. but as the dll is loaded it is not replaced by the new dll in that folder .
can any one suggest me a option for it????
Tryout are also welcome.Please suggest some technique to do this
|
|
|
|
|
If you close the dll, you can replace it. So long as the code is using the dll ( i.e. has it open ), you can't.
Or am I misunderstanding you ? You have the dll and just want to swap them without turning your main app off, right ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
actually u got the point right i have to change the dll and not swap.see i have a folder called ABC in this abc folder i am having my application app.exe and all called xyz.dll.
now my applixcation app.exe is running and it is using the xyz.dll.so the xyz.dll is loaded .Now i want to replace this xyz.dll in the folder and that loaded in the application i.e is app.exe. is it possible???
thanks for prompt reply
|
|
|
|
|
FreeLibrary() is the opposite of LoadLibrary(). But it doesn't guarantee that the dll will be unloaded and unlocked.
Signature space for rent. Apply by email to....
|
|
|
|