|
_NightOwl_ wrote: do you know how to open a file and lock it yourself that might give you an idea!!!
Yours Truly, The One and Only!
Actually, I want to check whether a file is locked by *any process*, be it my own app or any other process...
I'm aware of file locking functions when we open a file ourselves... but what about the files that are locked by some other app..?
-------------------------------------------------
No me, no life.. know me, know life..
|
|
|
|
|
I try setting the top index of the listbox to be anything, and it stays at zero for some odd reason. This listbox has an image under it in order to allow mouse over event. Each item's height is 13.
void __fastcall TfmMain1::lbTitlesMouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
int position = (ScrollBox1->VertScrollBar->Position)/13;
Label1->Caption = position;
lbVisible->TopIndex = 1;
lbTitles->TopIndex = position;
}
|
|
|
|
|
Hello All,
I am overriding "virtual BOOL OnIdle(LONG lCount );" method in my application.
i think it should execute befor application start mean after initinstance and also at the idle time
but it is not executing in my application.
can any one tell me what i have to do for override this method.
please share your knowledge.
thanks
bankey
|
|
|
|
|
Your OnIdle never gets called?
Have you seen this? OnIdle Member Function[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
Hello, now i read that document also but i am still unable to gets called "onIdle" method can you tell what i have to do for that.
also i have another application in which, onIdle method gets called at the time of start application and end application i also i want that
please tell me where i am wrong......
|
|
|
|
|
If your OnIdle() override isn't getting called then I'd guess that your app is dialog based and
your main dialog is modal.
In that case, you need to use the undocumented WM_KICKIDLE message:
afx_msg LRESULT OnKickIdle(WPARAM wp, LPARAM lp);
#include <afxpriv.h>
ON_MESSAGE(WM_KICKIDLE,&CMyMainDlg::OnKickIdle)
LRESULT CMyMainDlg::OnKickIdle(WPARAM wParam, LPARAM lParam)
{
return 0;
}
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
Hi,
Can anybody tell me how to get the list of usb devices which are connected to the system? Is there any Win32 API?
How will i know the USB version and speed of my system?
Regards,
Mayuresh
|
|
|
|
|
The short answer is, not easily. You must be the 20th person to post this question or one very close to it in the last couple of months. I have code that will do this but it is part of a commercial application so I can't simply post it
I looks like I'll finally have to give in and write an article describing it as so many people seem to want to know. It means putting other things on hold but watch this space.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Yes...Matthew, you should have to write an article which describes it and definately it will help others.
But at this momonet, can u atleast tell me the Win32 APIs, because I am relally stuck at this point? I used SetupDiGetClassDevs,SetupDiEnumDeviceInfo and SetupDiGetDeviceRegistryProperty APIs. but it gives all the devices. I want only USB devices connected to the system?
Please help me out...!
|
|
|
|
|
OK It sounds like you're most of the way there. You'll probably have something similar to this example this example[^] by now.
You need the GUID for USB devices, GUID_DEVCLASS_USB which lives in devguid.h which is part of the DDK. For maximum compatibility I used the one from \inc\w2k in the 3790.1803 version of the DDK which is available here[^]. You may be able to get this definition from the SDK headers these days, I'm not sure. If all you want is the USB devices of whatever type then that should be enough. If you want devices of a specific type e.g. disks then a call like this might be needed.
<br />
hIntDevInfo = SetupDiGetClassDevs (<br />
(LPGUID)&DiskClassGuid,<br />
NULL,
NULL,
(DIGCF_PRESENT | DIGCF_INTERFACEDEVICE
));<br />
The device type GUIDS like DiskClassGuid come out of winioctl.h
If you get a neat solution working I suggest you write that article yourself. You'll be a CP hero in no time
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
When a user activates a window (in the program I am writing) I was wondering what message it sends and what function I can use to add some additional functionality when this happens.
Thanks for any tips.
|
|
|
|
|
|
Hey,
Thanks for that, I combined it with
<br />
<br />
HWND SetFocus(HWND hwnd)<br />
<br />
I was able to add my own functionality.
|
|
|
|
|
Your question is sort of ambigious since everything is technicaly a window, even the controls on a dialog. For those, handle the WM_SETFOCUS message. For "main" windows, handle WM_ACTIVATEAPP or WM_ACTIVATE . There's also WM_SETACTIVE for property pages.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I have a method which has to return the array of BSTRs. I'm giving the method here, please let me know if I'm doing anything wrong.
HRESULT Login([in] BSTR UserName, [in] BSTR Password, int maxUsrCnt , [out]int *UsrCnt, [out, length_is(,*UsrCnt), size_is(,maxUsrCnt)] BSTR *LoggedUsers);
the size of the array to be returned is not known at the time of calling.
When I use this method, the first string is coming properly, but other strings are not coming.
Please suggest an answer.
Regards,
Raja Pratap
|
|
|
|
|
I never need to output the array back yet. I only guess that the last parameter should be declared as "BSTR **LoggedUsers". It is because: to output single string, should use "BSTR*". To output an array of strings, logically it should be "BSTR**". If my guess is correct, let me know.
|
|
|
|
|
I Tried with BSTR**, could not succeed. Only first string comes, since the marshaller considers only the first string, since length is not mentioned.
I got a hint from one of CP members to use SAFEARRAY(BSTR)* that worked fine.
|
|
|
|
|
Hi all,
I would like to know how I can make use of ofstream to count the total lines within a file, without looping through the file.
Many Thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Programm3r wrote: I would like to know how I can make use of ofstream to count the total lines within a file
Probably you need a istream .
Anyway you have to loop inside the file.
Using istream::getline may help.
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.
|
|
|
|
|
Thanks for the response CPallini ....
Like I said, I know one can do it in a loop. I.E
std::ifstream inFile;
inFile.open(lpfname, std::ios::in);
while (!inFile.eof())
{
inFile.getline(Str,STRING_SIZE);
lpzLineCounter++;
}
inFile.close();
Isn't there a single function that can perform the above code while using the fstream class??
Thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Programm3r wrote: Isn't there a single function that can perform the above code while using the fstream class??
No (AFAIK).
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.
|
|
|
|
|
what about using the count_if()[^] algorithm with '\n' ?
|
|
|
|
|
I bet internally, though, that it uses a loop!
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
oh, yeah, certainly... but from our side, it's much simpler to write, so why bother, eh ?!
|
|
|
|