I have a program that manages documents on a central area in the network and I need to tell if a file is in use by someone ele, when I try to open it. The program runs on each machine that access the central archive (no program runs on the server that holds the files). What is the right or the best way to do it ? Can I try to lock the file or rename it and see by the error returned if the file is open ? Is there any API function that tells me that ? If it´s a Word Doc, for instance, the Word gives me a hint, but Notepad doesn´t. I want to send my own msg to the user, despite of the app used to open the file. Is it possible ?
GeraldoLuiz
Posts
-
How to tell if a file is open by someone else -
How do i get full path to "My Documents" dir?Oh, thanks Tim for the advice. From now on, I will use the API call.
-
LV & TV strange behaviorI think the Edit control of the TreeView (for label editing) on a dialog doesn't handle the ENTER and ESC keys, so they are processed by the system DefDlgProc and directed to DEFPUSHBUTTON. But I think that it's kind of a bug, because the ListView Control does handle the ENTER and ESC keys. I will try to subclass the label edit control of the TreeView and handle the WM_GETDLGCODE message and see if it solves the problem.
-
How do i get full path to "My Documents" dir?You can also read the following registry key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal I use this in my programs. Geraldo.
-
LV & TV strange behaviorHi, I've never used label editing in TreeView & ListView before, so I guess it's a simple question. I used the EditLabels property (LVS/TVS_EDITLABELS) and create the controls. But a strange thing happens. I click on the label to edit and it's ok, but when I press any key (in both the TV and LV) the dialog is dismissed. Also, when I press ENTER (without any char has been pressed), they behave differently: the LV accepts it but the TV close the dialog. What is happening ? What is missing here ? I create a very simple test: a new Win32 App,typical HelloWorld, and include this lines in teste.rc: CONTROL "List1",100,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_EDITLABELS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,7,132,30 CONTROL "Tree1",200,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_EDITLABELS | TVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,7,43,158,24,WS_EX_CLIENTEDGE and include InitCommonControls(); at WinMain and #include "commctrl.h" and put comctl32.lib in the project settings finally I put this on the About function: case WM_INITDIALOG: LVCOLUMN col; col.mask = LVCF_TEXT | LVCF_WIDTH; col.pszText = _T("Col1"); col.cx = 100; ListView_InsertColumn(GetDlgItem(hDlg, 100), 0, &col); LVITEM lv; lv.mask = LVIF_TEXT; lv.pszText = _T("Txt1"); lv.iItem = 0; lv.iSubItem = 0; ListView_InsertItem(GetDlgItem(hDlg, 100), &lv); TVINSERTSTRUCT tv; tv.hInsertAfter = TVI_LAST; tv.item.mask = TVIF_TEXT; tv.hParent = TVI_ROOT; tv.item.pszText = _T("root"); TreeView_InsertItem(GetDlgItem(hDlg, 200), &tv); return TRUE; and that's it. I didn't include the handlers to LVN/TVN_BEGINLABELEDIT and ENDLABELEDIT , but I think this is not the problem. Why the dialog is dismissed when I press any key ? Why the ENTER key is OK with LV but close the dialog in TV ? Did I forget to handle some message or notification here ? Did they act differently in Windows and Dialogs ?
-
dynamic DefPushButtonOk, David, that's it. I didn't know this message. I will give it a try. Thanks a lot for pointing me in the right direction.
-
dynamic DefPushButtonI have a modal dialog with an OK button with BS_DEFPUSHBUTTON style but when the focus is on a particular textbox, I want to change the DefPushButton to another one, so when the user press ENTER the action is related to that field. I tried to redefine it using SetButtonStyle(), but it doesn't work. The button visually seems to receive the Default focus, but whem I press ENTER the old default one is clicked. If I take the DEF style from the old one, then no action happens when I press ENTER. Then, a strange thing happens with the focus when I tab into the button. When I move the focus to the button with the tab key, it seems like it receives the focus (dotted rectangle inside) but is not in selected state. Is it possible ? Can I change the default button dynamically or windows prevent it ? How can I accomplish such a thing ? Thanks.
-
CString to IntegerHi, You can also use the Win32 API (Shell API) function if you want to avoid the CRT (C Run-Time Library) (If you use ATL/WTL for example) StrToInt(LPCTSTR lpSrc); Also check the others string functions from Win32 API (Platform SDK) and the Shell API (shlwapi.h). They mimic almost every string function from C++ library. Geraldo.
-
SubclassingI want to subclass some combobox controls on a dialog to handle WM_KEYDOWN msg (to delete contents using DEL key). 1. I`m using CContainedWindow. I use the function: OnKeyDown(TCHAR nChar, UINT nRepCnt, UINT nFlags) with MSG_WM_KEYDOWN in ALT_MSG_MAP(1). For one control, it's ok (works fine), but what if I want to subclass more than one and redirect all WM_KEYDOWN msgs to the same function ? How can I tell what control is receiving the message ? The m_hWnd member points to my dialog wnd. 2. I also tried the DDX way, using DDX_CONTROL and defining: class CCombo: public CWindowImpl and defining my controls of this class, but the compiler gives me an error saying that SubclassWindow is not a member of CComboBoxT How can I do it using #1 and what am I doing wrong with #2 ? Thanks.
-
"Files are out of date"I'm not using sourcesafe. I solved the problem this way: I created a new project, created every cpp and h file empty (it must have been 12 files) and then copied and pasted the source files one by one and after. It took me all day long, but now I have a working copy again. Very strange. I kept the old copy to play with when I got time. I hope it won't happen again. Thanks.
-
"Files are out of date"All of a sudden, Visual Studio started to give me the message "One or more files are out of date or do not exist" and list all my obj files (and bsc and exe too), everytime I click Execute Program (Ctrl-F5) or Go (F5). It's ok if the files are really outdated, but the problem occurs after I Rebuild All and then Execute. And it compiles and build all the sources over and over. It is happening only with the project I'm working on. I tried others and it works fine. Any suggestions ? Thanks Geraldo