|
Separating the class declarations and definitions to different files would help you to compile the project. Also you may need to make A m_a; in the class be as A* m_a;
a.h
--------
#ifndef CLASS_A
#define CLASS_A
class B;
class A
{
public:
B* p_b;
void fun();
};
#endif
a.cpp
-----
#include "stdafx.h"
#include "a.h"
#include "b.h"
void A::fun()
{
p_b->funB(); // error: can not find class B::funB
}
b.h
-----------------
#ifndef CLASS_B
#define CLASS_B
class A;
class B
{
public:
A* m_a;
void funB();
};
#endif
b.cpp
-------
#include "b.h"
void B::funB()
{
printf("funb");
}
HTH
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
I have a calculation DLL that display a dialog with a progressbar.
So when an application calls this DLL function, the progress dialog is displayed untill the calculation is complete.
But the problem is, when I remove the focus from the calling application (click on another application in the windows taskbar) and re-set the focus on the calling application (re-selecting the the calling application in the windows taskbar) while the DLL is calculating and displaying the progress dialog. The calling application will display but the progress dialog remians minimized in the taskbar. I need the progressdialog to display on top of the calling application when I re-set the focus on the calling application.
I've tried using SetForegroundWindow() on the progress dialog, but the problem I had with this is, that you don't have control over any of the windows in the background untill the calculation DLL is complete. I must have control of the background windows while the DLL is calculating. I've also set the Topmost property but it had no effect.
Any ideas?
|
|
|
|
|
pass the handle of the main dialog to the dll and in dll while creating the progess dialog, set the main dialog as parent window.
nave
|
|
|
|
|
The main dialog is an exe (NI TestStand), not something that I wrote, so I don't know if it is possible to obtain a handle of the main dialog and pass it into the DLL? Maybe I can try and get the handle of the caller app from within the DLL?
I've tried to used AfxGetApp() but it ends up giving the handle to the DLL.
|
|
|
|
|
If you call AfxGetMainWnd() from the same thread in which the exe created the main dialog, you can get the handle of it.
If that too dosent worked, there is FindWindow() na?
nave
|
|
|
|
|
fusion2344X wrote: I have a calculation DLL that display a dialog...
Modal or modeless dialog?
"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
|
|
|
|
|
Is it possible to get total folder size, I use SHBrowseForFolder(LPBROWSEINFO lpbi) function? Or do I need to browse each file inside folder and use CFile::GetLength() and add up to retrive folders's total size?
Thx
|
|
|
|
|
|
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
|
|
|
|