|
Use EnableWindow(FALSE) .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Disabling a radio button doesn't change the state of it. If it's selected/checked before disabling, it will remain selected/checked but dimmed.
|
|
|
|
|
Yes, but you can't tell the radio button is selected by looking at it (it loses the black circle indicating selection). You can access that information in code, but how does the user know what was previously selected?
|
|
|
|
|
Normally, its visual state (black circle) shouldn't be changed, too, except for dimming, of course. Normally means, at first, your radio button is in windows' standard RADIOBUTTON class (or its MFC counterpart, CButton).
It's possible that it may be an owner draw button or sub-classed one or even a complete custom control. if so, the problem may be with its drawing routine.
Sometimes, OS itself shows some strange behavior due to a sw./hw. problem (may be graphic card driver). I recommend to try it on another machine.
Although I think that this is standard behavior, (latest) windows version differences should also be considered (e.g. Windows7, Vista).
|
|
|
|
|
So, this isn't the same request as most other requests of this topic.
My idea is to hook it just for one particular application. I'm desiring to sandbox an application, aka application virtualization.
So, take a written application, wrap it with my code which hooks all the CreatefileA, CreatefileW, etc... made by this application. I assumed it would be easier than hooking the system api, but honestly, I'm not so sure after I've been looking around!
My hope is to start an open source application virtualization which will be like ThinApp (Thinstall), and the microsoft one too.
Any ideas, or pointers to existing open source projects? (I haven't found one...)
Dave Smith
|
|
|
|
|
Perhaps Detours[^] will help you.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Can you modify how the application is built? If so, you could create a replacement for kernel32.lib, user32.lib etc that the application could link against. This CP article[^] could help with creating the interception DLL
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Does anyone knows how to create a dynamic recorset in c++? like in VB recordset rs=new adodb.recordset, rs.fields.add...
|
|
|
|
|
|
rajeshkumar1.s wrote: Does anyone knows how to create a dynamic recorset in c++?
What about:
recordset rs = new recordset();
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Great!
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
[My articles]
|
|
|
|
|
I've got a custom control class that derives from CStatic that should handle WM_RBUTTONUP within its code. unfortunately this message is always redirected to the parent window (a CDialog). What can i do?
Don't try it, just do it!
|
|
|
|
|
Just a guess here but does your static maybe have the SS_NOTIFY style set? If yes then try removing it.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Ah thx, I found it. When SS_NOTIFY isn't set the static control doesn't answer WM_NCHITTEST with HTCLIENT so the messages go to the parent window.
Don't try it, just do it!
|
|
|
|
|
MFC, STUDIO 2008
Help me, please alignment dialog window after
it appear on screen to right side of screen.
Thank you.
|
|
|
|
|
You can use MoveWindow() or SetWindowPos() for this.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Greetings!
I want to enumerate all devices connected to a USB port on my PDA (it`s USB Host and I connect 1 memory stick)
I have a problem enumerating the devices connected to the USB port, which is the very first step.
I get a "0" return when calling the function, even if there is a memory stick attached, which works in the Operating system.
This approach is the classical one, where you ask for device info in order to open a connection.
Here you can find the VC++ 8.0 project for testing pourposes, I have commented the unnecesary code, what`s left is VERY simple.
http://rapidshare.com/files/242608616/USBXpress2_MFC.rar.html[^]
I`m surprised it doesn`t work and I have no idea what's the problem... Can you give me a hint ?
In order to run the application on the smart device itself, you must add the file "SIUSBXP_LIB.dll" to the WINDOWS directory. If you don`t want to do this, I'll tell you what happens:
In USBXpress2_MFCDlg.cpp, the call on line 103 returns 0 (no devices) instead of anything else.
I have tested a memory stick that is being accessed by the Operating System, but this application fails to access it.
Again, the call is very simple...
The SIUSBXP_LIB.lib (and .dll) files are downloaded from the Sylicon Laboratories site, I`m using their files to make a connection between my PDA and my device.
The download link for the project:
Thanks for any possible help!
Vlad
|
|
|
|
|
You might try posting here the exact code that has the problem.
I don't think anybody is going to go download your project and debug it themselves.
Please make your question specific.
|
|
|
|
|
Ok, I`ll try to create the context here. It`s hard to do that, because every function or a parameter is a typedef of a typedef... etc... anyway:
The line that makes me problems: (code in my .cpp file)
DWORD numDevices = 0;
SI_GetNumDevices(&numDevices);
This piece of code returns 0 (the function SI_GetNumDevices does not affect it's value)
Now, this doesn`t tell us anything, therefore:
Definition of SI_GetNumDevices: (in the file header it comes with the dll)
typedefs/defines:
#define SI_USB_XP_API __declspec(dllimport)<br />
typedef int SI_STATUS;<br />
typedef DWORD far *LPDWORD;<br />
#ifdef __cplusplus
extern "C" {
#endif
SI_USB_XP_API
SI_STATUS WINAPI SI_GetNumDevices(
LPDWORD lpdwNumDevices
);
#ifdef __cplusplus
}
#endif
When I search lpdwNumDevices (find all references) the programming tool reports no references, no definitions, no declarations... ??
I have 0 experience working with exterior dlls and libs, and this piece of code was found in one of the examples it comes with the usb fileset. Therefore, I expect it to be a mistake of mine in setting everything in the right way, as the code is likely to be flawless (in its original state) ...
|
|
|
|
|
I might add that the return value of the SI_GetNumDevices is SI_DEVICE_NOT_FOUND - #define of value 255.
So there must be a problem with the hardware, or how I`m connecting it (libraries I suppose) and not this code...
|
|
|
|
|
<pre> I have a question regarding sockets. I am trying to write two programs that will establish connection between each other to send and receive massages. One program sets connection the code is the following:
WSADATA WsaData;
int err = WSAStartup (0x0101, &WsaData);
s = socket(AF_INET,SOCK_STREAM,0);
fer<<"socket error code="<<WSAGetLastError()<<endl;
SOCKADDR_IN anAddr;
anAddr.sin_family = AF_INET;
if (!cm.onemach)
anAddr.sin_port = htons(tcomp->m_port);
else
anAddr.sin_port = htons(1026);
if (!cm.onemach)
anAddr.sin_addr.S_un.S_addr = inet_addr(tcomp->m_ipadr);
else
anAddr.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
UINT TimeLimit=t;
BOOL connected;
if (connect(s, (struct sockaddr *)&anAddr, sizeof(struct sockaddr))==0)
connected=TRUE;
else
connected=FALSE;
fer<<"connecting error code="<<WSAGetLastError()<<endl;
if (!connected)
return FALSE;
{
err=send(s,sendMessage,strlen(sendMessage),0);
if (err!=0)
{
fer<<"sending error code="<<WSAGetLastError()<<endl;
}
}
And the other accepts connection:
WSADATA wsaData;
int wsaret=WSAStartup(0x0101,&wsaData);
if (wsaret == SOCKET_ERROR) AfxMessageBox("error");
while (flag)
{
servr= socket(AF_INET,SOCK_STREAM,0);
if (servr == INVALID_SOCKET)
{
flag=TRUE;
fer<<"getting message/ creating error code="<<WSAGetLastError()<<endl;
}
else
flag=FALSE;
}
anAddr.sin_family = AF_INET;
anAddr.sin_port = htons(1026);
anAddr.sin_addr.s_addr = INADDR_ANY;
err=-1;
while (err==-1)
{
err=bind( servr, (LPSOCKADDR)&anAddr, sizeof(anAddr) );
if (err!=0)
{
fer<<"binding error code="<<WSAGetLastError()<<endl;
Sleep(1000);
}
}
err=-1;
while (err!=0)
{
err = listen( servr, SOMAXCONN); //SOMAXCONN defined as 5
if (err!=0)
{
fer<<"listening error code="<<WSAGetLastError()<<endl;
Sleep(500);
}
}
SOCKADDR_IN from;
int fromlen=sizeof(from);
fer<<"before accepting error code="<<WSAGetLastError()<<endl;
//gets the address and port of remote/distant comp.
Recv=accept(servr,(struct sockaddr*)&from, &fromlen);//waits for not defined time
fer<<"accepting error code="<<WSAGetLastError()<<endl;
Last time, when I put the question I have been suggested to get WSAGetLastError(). Now I am trying this way and again the program sometimes works correct and sometimes doesn’t work and gives error 10061: Connection refused.
No connection could be made because the target computer actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host—that is, one with no server application running.
Even so the second program waits on accept function the connection is not established. I will appreciate it greatly if anyone can tell me where the error comes or what can be the reason that sometimes it works and sometimes – no, can it be something with socket options or AF_INET address family. Thanks in advance.
|
|
|
|
|
- please don't post and repost again the same question: you may edit the OP.
- use the
<pre> tag to surround code snippets, for instance <pre> code here </pre> .
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
[My articles]
modified on Tuesday, June 9, 2009 9:19 AM
|
|
|
|
|
<pre> I have a question regarding sockets. I am trying to write two programs that will establish connection between each other to send and receive massages. One program sets connection the code is the following:
WSADATA WsaData;
int err = WSAStartup (0x0101, &WsaData);
s = socket(AF_INET,SOCK_STREAM,0);
fer<<"socket error code="<<WSAGetLastError()<<endl;
SOCKADDR_IN anAddr;
anAddr.sin_family = AF_INET;
if (!cm.onemach)
anAddr.sin_port = htons(tcomp->m_port);
else
anAddr.sin_port = htons(1026);
if (!cm.onemach)
anAddr.sin_addr.S_un.S_addr = inet_addr(tcomp->m_ipadr);
else
anAddr.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
UINT TimeLimit=t;
BOOL connected;
if (connect(s, (struct sockaddr *)&anAddr, sizeof(struct sockaddr))==0)
connected=TRUE;
else
connected=FALSE;
fer<<"connecting error code="<<WSAGetLastError()<<endl;
if (!connected)
return FALSE;
{
err=send(s,sendMessage,strlen(sendMessage),0);
if (err!=0)
{
fer<<"sending error code="<<WSAGetLastError()<<endl;
}
}
And the other accepts connection:
WSADATA wsaData;
int wsaret=WSAStartup(0x0101,&wsaData);
if (wsaret == SOCKET_ERROR) AfxMessageBox("error");
while (flag)
{
servr= socket(AF_INET,SOCK_STREAM,0);
if (servr == INVALID_SOCKET)
{
flag=TRUE;
fer<<"getting message/ creating error code="<<WSAGetLastError()<<endl;
}
else
flag=FALSE;
}
anAddr.sin_family = AF_INET;
anAddr.sin_port = htons(1026);
anAddr.sin_addr.s_addr = INADDR_ANY;
err=-1;
while (err==-1)
{
err=bind( servr, (LPSOCKADDR)&anAddr, sizeof(anAddr) );
if (err!=0)
{
fer<<"binding error code="<<WSAGetLastError()<<endl;
Sleep(1000);
}
}
err=-1;
while (err!=0)
{
err = listen( servr, SOMAXCONN); //SOMAXCONN defined as 5
if (err!=0)
{
fer<<"listening error code="<<WSAGetLastError()<<endl;
Sleep(500);
}
}
SOCKADDR_IN from;
int fromlen=sizeof(from);
fer<<"before accepting error code="<<WSAGetLastError()<<endl;
//gets the address and port of remote/distant comp.
Recv=accept(servr,(struct sockaddr*)&from, &fromlen);//waits for not defined time
fer<<"accepting error code="<<WSAGetLastError()<<endl;
Last time, when I put the question I have been suggested to get WSAGetLastError(). Now I am trying this way and again the program sometimes works correct and sometimes doesn’t work and gives error 10061: Connection refused.
No connection could be made because the target computer actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host—that is, one with no server application running.
Even so the second program waits on accept function the connection is not established. I will appreciate it greatly if anyone can tell me where the error comes or what can be the reason that sometimes it works and sometimes – no, can it be something with socket options or AF_INET address family. Thanks in advance.
|
|
|
|
|
Are you using some tutorial or sample for this? If not you should be. There are a million of them on the web. There have been for like a decade now. Your use of htons to set port numbers is totally unnecessary and suggests that you need to study more about using sockets. One web site that has existed since like 1995 is Sockets.com. You should check it out.
|
|
|
|
|
I have read various statements in this forum saying things like "it's more efficient to x" or "x is inefficient, I'd try y", or the more helpful "x is terribly inefficient, I'd look for a better method."
How do I determine what is efficent/inefficient, or, more specifically, given two algorithms to accomplish a task, how do I determine which is more efficient?
As a relevent example, I have an object whose member vars need to be backed up by a file, and needs to support multiple instances sharing a file (and therefore values); any time the member vars are modified, the file needs to be updated. File access has to be synchronized through IPC.
A first algorithm would be to synchronize file access within the main process, create the object after getting ownership of the sync object, read the file contents after object creation, modify the vars, write to the file, then destroy the object.
A second algorithm would be to have the main process create the object and maintain it through the main process' lifetime, have the IPC synchronization handled within the object whenever the vars are modified.
A third would be to have the main process create and maintain the object, handle synchronization within the main process, and pass a file handle from the main process to the object methods that modify the vars so they can modify the file.
A fourth would be to have the main process create and maintain the object, handle synchronization within the main process, and have the object use a memory-mapped file to maintain the vars.
A fifth would be the same as the fourth, only handling synchronization within the object.
...and I'm sure I could come up with more...
My limited experience has me leaning towards either the second or the fifth as theoretically most-efficient, but how would I go about actually determining this ?
As always, any answers, or suggestions what I should read, are greatly appreciated.
MZR
P.S.
Then, of course, there's also the question of "execution efficiency" (speed) and "memory efficiency." Is the most memory-efficient always the fastest-executing?
|
|
|
|
|