|
Hello,
I have changed icon for my child window by defining a window class in a non Doc-View architecture
lpszClass = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW,
LoadCursor(NULL, IDC_ARROW),
HBRUSH) (COLOR_WINDOW+1),
LoadIcon(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ICON1)));
But I am not able to change the menu for my child window.
I tried by doing the following in ChildFrame's
PreCreateWindow(CREATESTRUCT& cs)
{
cs.lpszName = "my Window";
cs.hInstance = AfxGetInstanceHandle();
CMenu M;
M.CreateMenu();
M.AppendMenu(MF_CHECKED ,MF_OWNERDRAW,"sasas");
M.AppendMenu(MF_CHECKED ,MF_OWNERDRAW,"sassaaaa");
cs.hMenu = M;
}
Where I went wrong ?
Or if the above code is not clear .then can you tell me how should I change menu for my child windows
Prithaa
|
|
|
|
|
Hi,
from VC++ Help:
The CREATESTRUCT structure has the following form:
typedef struct tagCREATESTRUCT {
LPVOID lpCreateParams;
HANDLE hInstance;
HMENU hMenu;
HWND hwndParent;
int cy;
int cx;
int y;
int x;
LONG style;
LPCSTR lpszName;
LPCSTR lpszClass;
DWORD dwExStyle;
} CREATESTRUCT;
The CREATESTRUCT structure defines the initialization parameters passed to the window procedure of an application.
Members
lpCreateParams: Points to data to be used to create the window.
hInstance: Identifies the module-instance handle of the module that owns the new window.
hMenu: Identifies the menu to be used by the new window. If a child window, contains the integer ID.
Maybe is there?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
You should not do it in child frame.
Either do it in MainFrame or call Parent window in child window.
The following code should work. (but i have not tested it.)
PreCreateWindow(CREATESTRUCT& cs)
{
cs.lpszName = "my Window";
cs.hInstance = AfxGetInstanceHandle();
CMenu* pMenu; // Create a pointer to the current menu.
CWnd* pParent = GetParent();
pMenu= pParent->GetMenu(); // Get the menu.
pMenu->CreateMenu();
pMenu->AppendMenu(MF_CHECKED ,MF_OWNERDRAW,"sasas");
pMenu->AppendMenu(MF_CHECKED ,MF_OWNERDRAW,"sassaaaa");
cs.hMenu = pMenu;
}
Wish u all the best.
Anurag Gandhi.
|
|
|
|
|
Hello gurus,
I'd like to know if some one knows in which Win32 headers lib is the __loctotime_t function?
Thanks for the help.
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
|
may be you can get some help here[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Actually this function is undocumented in MSDN.
The project I have to port on vista, links when I use VC++6 (on WinXP) but does neither compile nor link on VS2005 (on Vista/XP).
Any idea?
Thanks in advance.
There is no spoon.
|
|
|
|
|
bouli wrote: I'd like to know if some one knows in which Win32 headers lib is the __loctotime_t function?
Well, the function is declared in internal.h , but that file is not intended for public use. Why the dependency on this function?
"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
|
|
|
|
|
Ok,
I have finally found a documented alternative: mktime .
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
I am using the following function to find out whether I can connect to a particular IP address(for ex:3.205.202.6 etc...) in VC++.
This function returns TRUE on Windows 2000 if the given IP address is communicating one. But on Windows XP system it always returns FALSE (However I can still say ping to this IP :- 3.205.202.6 from DOS command prompt. It replies correctly).
Can anyone please help me to root cause this issue in Windows XP system. Is this socket API not valid on Win XP system? On Win2000, it always gives me the correct status.
BOOL IsOnline(const CString &strIPAddr)
{
SOCKET tmpSocket;
struct sockaddr_in SClient;
u_long argp;
fd_set stReadFDS;
fd_set stWriteFDS;
fd_set stExceptFDS;
struct timeval stTimeOut;
int nSelectReturn;
DWORD nTicks;
DWORD nTickStart;
//create a socket
tmpSocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) ;
if (tmpSocket == INVALID_SOCKET)
{
return FALSE;
}
// make the socket non blocking
argp = 1L; // non zero enables nonblocking mode
if (ioctlsocket(tmpSocket, FIONBIO, (u_long FAR *) &argp) == SOCKET_ERROR)
{
closesocket(tmpSocket);
return FALSE;
}
// connect to the given IP address
SClient.sin_family = AF_INET;
SClient.sin_port = htons(502);
SClient.sin_addr.s_addr = inet_addr(strIPAddr);
int nLastErr;
if (connect(tmpSocket, (sockaddr *) &SClient, sizeof(sockaddr_in)) == SOCKET_ERROR)
{
nLastErr = WSAGetLastError();
if (nLastErr != WSAEWOULDBLOCK)
{
closesocket(tmpSocket);
return FALSE;
}
nTicks = 500;
nTickStart = GetTickCount();
nSelectReturn = SOCKET_ERROR;
int ic = 0;
while (nSelectReturn <= 0 && (GetTickCount() - nTickStart) < nTicks)
{
// clear all sockets from FDS structure, then put our socket into the socket descripter
FD_ZERO(&stReadFDS);
FD_ZERO(&stWriteFDS);
FD_ZERO(&stExceptFDS);
FD_SET(tmpSocket, &stReadFDS);
FD_SET(tmpSocket, &stWriteFDS);
FD_SET(tmpSocket, &stExceptFDS);
// set a timeout of 1 second
stTimeOut.tv_sec = 1;
stTimeOut.tv_usec = 0;
nSelectReturn = select(-1, &stReadFDS, &stWriteFDS, &stExceptFDS, &stTimeOut);
if (nSelectReturn == SOCKET_ERROR)
{
nLastErr = WSAGetLastError();
if (nLastErr != WSAEINPROGRESS)
{
closesocket(tmpSocket);
return FALSE;
}
}
}
if (nSelectReturn <= 0 || stWriteFDS.fd_count == 0)
{
closesocket(tmpSocket);
return FALSE;
}
}
closesocket(tmpSocket);
return TRUE;
}
Thanks
|
|
|
|
|
Check your Firewall settings
Greetings from Germany
|
|
|
|
|
Setttings are the same in both....
|
|
|
|
|
The only thing I see right away is that your timeout value is pretty short. Half a second...
Factor in the accuracy of clock ticks and it often could be much shorter.
For what it's worth, here's an alternative method using an event instead of looping (which is
inefficient use of CPU!)...
tmpSocket = ::socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) ;
if (tmpSocket != INVALID_SOCKET)
{
BOOL fConnectSuccess = FALSE;
HANDLE hNetEvent = ::CreateEvent(NULL, true, false, NULL);
::WSAEventSelect(tmpSocket, hNetEvent, FD_CONNECT);
sockaddr_in SClient;
SClient.sin_family = AF_INET;
SClient.sin_port = htons(502);
SClient.sin_addr.s_addr = inet_addr(strIPAddr);
if (SOCKET_ERROR == ::connect(tmpSocket, (sockaddr *) &SClient, sizeof(sockaddr_in)))
{
int rc = WSAGetLastError();
if (rc == WSAEWOULDBLOCK)
{
if (WAIT_OBJECT_0 == ::WaitForSingleObject(hNetEvent, 10000))
{
WSANETWORKEVENTS WsaNetworkEvents;
if (0 == ::WSAEnumNetworkEvents(tmpSocket, hNetEvent, &WsaNetworkEvents))
{
if (0 != WsaNetworkEvents.iErrorCode[FD_CONNECT_BIT])
{
}
else
{
fConnectSuccess = TRUE;
}
}
}
else
{
}
}
else
{
}
}
else
{
fConnectSuccess = TRUE;
}
::closesocket(tmpSocket);
::CloseHandle(hNetEvent);
return fConnectSuccess;
}
else
{
return FALSE;
}
-- modified at 13:42 Wednesday 23rd May, 2007
added cleanup for event handle
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi,
Having a problem in parsing XML. I am MSXML 4.0 api to parse a custom defined xml file which store different data related to a specific trace. It is like this
<DataSet>
<LG1>
<LG2>
<LG3>
........
</DataSet>
No. of child element under DataSet is unknown. It varies with the no. of data available during save.
Here I can't use selectNodes api call with parent element (MSXML2::IXMLDOMElement) to collect all child element starts with LG. Is there any way to solve this problem. Can I create a element list containing all element start with "LG"
Thanks in advanve....
Regards
Sandipan.
Sandip
|
|
|
|
|
If you can modify the XML file, would'nt it be nicer to make it in this way?
<DataSet>
<LG>
<1>
<2>
...
</LG>
</DataSet>
Then you could search for the LG node and get all the childs directly...
Hope this helps.
|
|
|
|
|
Dear joan,
Thanks for your candid advice. But the problem is like that only and I am looking for a way out to solve it. But anyway thanks for the reply.
Sandip
|
|
|
|
|
Well, the saving function should put in a tag into the stream that indicates the number of nodes.
Can you use simple text processing to get at the data? There have been very few situations like this where I could not quickly skip through the data using something simple as memory-mapping the XML file and walking through the file data. Hell, for your example above, even using _tcsstr( cpXMLStream, _T( "<LG" ) ) would likely work allowing you to get at each LG node...
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
I'm trying to register a DLL created by Visual Studio 2005 in Debug Mode.It fails with the return code as 0xc0000005.
What is the prime reason for this error?.I have full administrative rights on my machine. Also, the Release DLL registration succeeds for the Same project...
Rane
|
|
|
|
|
Rane wrote: It fails with the return code as 0xc0000005.
Does it fail on your development machine, or another machine?
|
|
|
|
|
On all Machines...
Rane
|
|
|
|
|
Use dependency walker, Depends.exe ("Program Files\Microsoft Visual Studio\Common\Tools\DEPENDS.EXE") for checking the dependency of your dll. Provide all the dependent dlls. Hope this would serve your purpose.
Regards,
Paresh.
|
|
|
|
|
Rane wrote: I'm trying to register a DLL created by Visual Studio 2005 in Debug Mode.It fails with the return code as 0xc0000005.
Are you using regsvr32.exe ?
"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
|
|
|
|
|
Well I am working on VC++ and I wish to develop an application that creates an xml file. Can anybody guide ??
-- modified at 2:38 Wednesday 23rd May, 2007
|
|
|
|
|
kunal.tawde wrote: Well I am working on VC++ and I wish to develop an application taht creates an xml file. Can anybody guide ??
MSXML[^
Look up this[^] too.
|
|
|
|
|