|
I have a volume control prog. downloaded and written the necessary hotkey code lines based on
Beginner's Tutorial - Using global hotkeys
http://www.codeproject.com/system/nishhotkeys01.asp
into it.
The hotkey succesfully registers.
RegisterHotKey(this->m_hWnd, myatom, MOD_CONTROL, VK_UP)
on querying this line I get a true
in the header:
public:
...
LRESULT OnHotKey(WPARAM wParam, LPARAM lParam);
...
DECLARE_MESSAGE_MAP()
in the correspondig cpp file:
BEGIN_MESSAGE_MAP(CVolumeControlDemoDlg, CDialog)
//{{AFX_MSG_MAP(CVolumeControlDemoDlg)
... // some more messages
ON_MESSAGE(WM_HOTKEY,OnHotKey)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
and also in the cpp file:
LRESULT CVolumeControlDemoDlg::OnHotKey(WPARAM wParam, LPARAM lParam)
{
if(wParam == MOD_CONTROL && lParam == VK_UP) {
log.write("!!! HOTKEY PRESSED SUCCESS !!!");
}
return 0;
}
on pressing the hotkey while the prog is running -> NOTHING happens. But if I call the following line in the code I get the WM_HOTKEY message correctly:
SendMessage(WM_HOTKEY, MOD_CONTROL, VK_UP);
What am I doing wrong? Plz in very easy language since I am a programming N00b. TY
|
|
|
|
|
Hi,
I am using InternetGetConnectedState to determine, whether a LAN connection exists.
IBZHTTP_API LRESULT canConnectLAN() {
DWORD dwFlags;
InternetGetConnectedState(&dwFlags,0);
return LRESULT( 0 < (dwFlags & INTERNET_CONNECTION_LAN) );
}
I tested this function on two computers(PC1, PC2), both connected to the same LAN. Both have additionally RAS installed and a proxy exists. The LAN connections are activated.
PC1: Return value dwFlags is 56, which is correct, it means
INTERNET_CONNECTION_LAN (0x02)
INTERNET_CONNECTION_PROXY (0x04)
INTERNET_RAS_INSTALLED (0x10)
INTERNET_CONNECTION_CONFIGURED (0x40)
PC2: Return value dwFlags is 50 which is not enough, it means only
INTERNET_RAS_INSTALLED (0x10)
INTERNET_CONNECTION_CONFIGURED (0x40)
When RAS connections with modem are defined on PC2, dwFlags is correct with respect to RAS, 51:
INTERNET_CONNECTION_MODEM (0x01)
INTERNET_RAS_INSTALLED (0x10)
INTERNET_CONNECTION_CONFIGURED (0x40)
What could be the reason, that InternetGetConnectedState does not report the LAN connection on PC2?
Thank you
Werner
|
|
|
|
|
Hi,
I have an application which accesses an archive file. And my application is multi instance application. When I open an archive file in the first instance of the application then I Should lock that archive file so that when I try to open the same archive file (which is locked in the first instance) in the second instance of the application then application should give error or throw an exception.
Plz, help me in this.
Any adea/code sample?
Thanks & Regards,
Neeraj
|
|
|
|
|
Hi Neeraj,
Use CFile::shareDenyRead,CFile::shareDenyWrite, or CFile::shareExclusive as a nOpenFlags for Open function.
Regards
Alpha
|
|
|
|
|
Thanx Alpha.
The use of CFile::shareDenyRead,CFile::shareDenyWrite, or CFile::shareExclusive flags will help when two users/processes are trying to acess the same file at the same time.
But in my application I open a file in the first instance of application and and I close it(Here after opening file I should lock the file). Unless I unlock that file (which I lock in first instance) OS should not allow to open by other process/other instance of application.
Thanks & Regards,
Neeraj
|
|
|
|
|
You can use LockRange function for this and use UnlockRange whenever you want to Unlock this.
Regards
Alpha
|
|
|
|
|
If you are denying read/write access to the file when it is opened, why do you need to bother with locking?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanx David.
But,I am using the wordspace file in my application. Here I open the file, read it and close it. Again I open the file, write to it and close it. It is several times.
What I need is one perticular workspace file can be accessed by only one instance of the application. i.e. I should not be able to work on the same workspace file from two different instance of the same application.
When I access the workspace file in first instance, all the data is copied to the application variables. When I save, the variable data is written back to workspace file. This happens several times.
While working on this workspace if I open the one more instance of the same application and start working on the same workspace file then there will be data mismatch/data loss etc. This should not happen.
So, when I access a workspace file from one instance of application then I should lock that file so that one more instanct of application should not able to access that file unless I unlock that workspace file.
How to do this?
Thanks & Regards,
Neeraj
|
|
|
|
|
If you open the file using the CFile::shareDenyxxx flags, that should allow the file to be opened only once. Does that not work for you?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanx David.
I think you did not get my explanation.
CFile::shareDenyxxx works when a file is opened by one instance of an application(file is still open i.e. not closed) and another instance of same application is trying to open the same file.
But in my case as already explained, I open the file, copy the data to application variables and close it. Now I start the second instance of application and try to open the same file(here file is closed by first instance) to copy data to application variables.
How do you restrict the second instance of application to access the same file unless some lock is removed from that file(there should be some way to lock that file)?
Now do you have any solution for this?
Thanks & Regards,
Neeraj
|
|
|
|
|
Neeranjan wrote:
I think you did not get my explanation.
Possibly, but with your revised explanation, the solution should be easier than ever.
Neeranjan wrote:
How do you restrict the second instance of application to access the same file...
At this point, the first instance of the application has closed the file so the file is once again able to be opened by any application, yours included.
If you are not wanting the second instance of the application to be able to open the file, even if the first instance of the application has closed it, you'll either need to have the first instance of the application leave the file open, or since both instances of the application share common code (e.g., the same CDocument object), set up some sort of variable that denotes "in use."
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanx David.
You mean, when a file is closed, there is no way we can restrict that file from accessing by any other application/process.
If it is the case then this will not solve my problem. I have to find some alternative for this.
Thanx David for your help and support.
Will be back with some more queries.
Thanks & Regards,
Neeraj
|
|
|
|
|
Neeranjan wrote:
You mean, when a file is closed, there is no way we can restrict that file from accessing by any other application/process.
Right. When a file is closed, it's closed!
Why is it that you are wanting to keep the second instance of your application from accessing the file?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
If you know the concept of workspace file then it will be easy to understand my explanation as below.
1. When I open a database file from my application, it loads the database file data in to application variables.
2. I perform some operation on the data, stored in application variables.
3. Now here I have two options:
a) I save the application variable data back to the database file.
b) I save the application variable data into a workspace file i.e. an archive file.
Workspace file: Is the copy of memory variables and data stored in variables on to the disk file.
4. Next time when I start the application I will have two options to load the data:
a) Open the database file and load the data in applicaiton variables.
b) Open the workspace file and load the data in applicaiton variables.
Suppose I have started the first instance of application and opened a workspace file(X) i.e. loaded data from workspace file into application variables. ( Here I have to close the file after loading the data, bcoz I will modify data and save data several times and some more things....)
Now I start the second instance of application and load the same workspace file (X).Here I will perform some operation and when I save it then it to workspace it will overwrite the file X even though first instance has modified the data and save back to workspace file X. Thus, here I loose the data saved by the first instance.
I think now you have been understood, why I need to lock a file which is already closed?
Now tell me, is there any solution for this problem?
Thanks & Regards,
Neeraj
|
|
|
|
|
Neeranjan wrote:
If you know the concept of workspace file
The only workspace file I am was familar with is that which is created by Visual Studio. In any case, it's just a file being opened/updated/closed by some application.
From what you've described, the solution, as I see it, is for the first instance to open the file for writing and only allow others read access. Don't close the file, but flush the output buffer after each update. When the second instance comes along, it will read an updated copy of the file.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi y'all. The problem is that the data I try to pass to the web service is received as NULL. Despite my best efforts I have not been able to find a solution to this problem anywhere on the net .
I send the data like this:
* create CInternetSession
* create CHttpConnection
* HttpConnection->OpenRequest(_T("POST"), _T("/CoreContact/WipCoreContact.asmx"),... to get a CHttpFile*
* set headers with pHttpFile->AddRequestHeaders
* finally call pHttpFile->SendRequest(NULL, 0, (LPVOID)((LPCTSTR)strSOAPReq), dwRewLen);
The response SHOULD read "This is your data, " + (parameter data) but the incoming data is always NULL as seen in the vs.net debugger.
This is what I send and get:
HEADERS
Content-Type: text/xml; charset=utf-8
Content-Length:351
SOAPAction: "http://tempuri.org/GetData"
REQUEST
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="
http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/en
velope/">
<soap:Body>
<GetData xmlns="http://tempuri.org">
<data>Hey hey service.</data>
</GetData>
</soap:Body>
</soap:Envelope>
RESPONSE
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetDataResponse xmlns="http://tempuri.org/">
<GetDataResult>This is your Data, </GetDataResult>
</GetDataResponse>
</soap:Body>
</soap:Envelope>
----------
Martin
|
|
|
|
|
hi all,
i'm sure it's stupid question but here it is:
how can i convert a floating point to hexa?
if i do this :
float n;
char temp[10];
n=10.0;
sprintf(temp,"%x",n);
and if n is integer than temp is 'A',but if n is float,temp is always 0;
can someone help me?
|
|
|
|
|
http://www.duke.edu/~twf/cps104/floating.html
----------
Martin
|
|
|
|
|
|
Hi everybody, Am in great trouble.
I have a project MyApp.exe which is a big project. It has some 20-30 dll dependencies on it. The resource (including dialog boxes) is in a separate dll. This project had been developed in VC6 previously and has now been ported to .NET. Its running fine.
The thing is, I want to make the dialog boxes appear with the Windows XP visual style. So, when an user selects Windows XP style from Control Panel->Appearance tab, the appearance of the dialogs should change too. It must not have the classic style appearance.
For this, I have followed the methods outlined in MSDN site. I am giving the links too.
1) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwxp/html/xptheming.asp
2) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/userex/cookbook.asp
Th process given above works fine for a simple dialog-based project.
But, where, even the resource is in a separate dll, there, it doesn't work.
PLEASE DO GIVE ME ANY FEEDBACK OR SUGGESTIONS ASAP.
Thanks and Regards,
Anind
|
|
|
|
|
Hi,
I want to add IP address programatically. Any idea how can I do this. I know of one function AddIPAddress, but it is for IPv4. Thanks for help.
Regards
Alpha
|
|
|
|
|
Hi, My questions deals with Template Functions.
I am suppose to code these functions and write a driver program to test them with various types of arrarys. Each templated function should work on any size array of any type.
<b>sortArrary</b> to sort an array in ascending order (using < comparison) <b>NOTE: I must pass the array and its size. I can use either a selection sort or an insertion sort. </b>
<b>searchArry </b> to look for a target element in a given arrary and return the locations or -1 if the target is not found. This is to be a binary search. <b>NOTE: I must pass in a <i>sorted</i> array, its size, and the target element</b>.
<b>deleteItem</b> to delete an item from an arrary. <b>NOTE: I have to pass in an arrary, its size, and the targe5t to be deleted. I must pass in a <i>sorted</i> array, its size, and the target element</b>.
I am having trouble writing these functions....
Thanks alot...Jason
|
|
|
|
|
This looks like a homework assignment, so I won't give you a ready solution, but will point out a few steps that will help you forward.
Templated functions are declared as follows:
template<typename Type>
void sortArray(Type* ptrArray, unsigned int nSize); This is a declaration of a templated function that takes a pointer to the first cell of the array, and the size of the array. To pass a whole array, change the first parameter to Type tgtArray[] .
The key is to first write a function that does the job for, say, an array of integers. Then, by interpreting and understanding the above declaration, you can easily change the function to support any type that has comparison operators (< and >) defined. This includes all basic types (int, char, float, double etc)
Hope this helps
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi all !
I read a code which contained a #pragma key. I researched in MSDN lib but can't understand detail it. Can you explain me about this keyword ? thank alot.
example: #pragma abc
hanhquang
|
|
|
|
|
There are defined pragma , you need to give exact code you read there.
#pragma abc is not valid pragma option.
|
|
|
|
|