|
I've got an MFC application writed in c++, it is a dialog-based project. I can't find anywere in the internet a solution for my problem. I've got a dialog window were i created a buttons. Also I've got two others dialog windows. I don't now how to make to open second dialog window when the button in window one will by clicked. I tried everything what i found in the internet and nothing ...
Please if any one can help me. I will be very thankfully if someone can send my or show how to do this.
HrDDD
|
|
|
|
|
in the handler of your button in dialog A (the first dialog), just create the second dialog.
for modal dialog:
void MyDialogA::OnButton()
{
MyDialogB dlg;
dlg.DoModal();
}
for modeless dialog:
class MyDialogA
{
MyDialogB* m_pDialogB;
}
void MyDialogA::OnButton()
{
if ( m_pDialogB)
delete m_pDialogB;
m_pDialogB = new MyDialogB;
m_pDialogB->Create(IDD_DIALOG_B);
m_pDialog->ShowWindow(SW_SHOW);
}
This signature was proudly tested on animals.
|
|
|
|
|
I can't find any function for calculate the time between LBUTTONDOWN and LBUTTONUP,help me ~
|
|
|
|
|
Here is a generic example on how to get elapsed time:
CTime startTime;
CTime endTime;
CTimeSpan elapsedTime;
On LBUTTONDOWN: startTime = CTime::GetCurrentTime();
On LBUTTONUP: endTime = CTime::GetCurrentTime();
elapsedTime = endTime - startTime;
int timeout = elapsedTime.GetSeconds();
|
|
|
|
|
wb_program wrote: I can't find any function for calculate the time between LBUTTONDOWN and LBUTTONUP,help me ~ Cool
Also probably you can use GetCurrentMessage which contains a DWORD value which gives the time the message was posted. Note that you should only call this from event handlers. So call this from mouse up and mouse down.
|
|
|
|
|
You can use 'GetDoubleClickTime' to retreive double click time for your mouse.
|
|
|
|
|
char *sConn="C:\\Documents and Settings\\Nimesh Gurung\\Desktop\\VPassignment\\Employee.mdb";
m_ptrConnection.CreateInstance(__uuidof(Connection));
m_ptrConnection->Provider = "Microsoft.Jet.OLEDB.4.0";
m_ptrConnection->Open(sConn,"Admin","",NULL);
//Create Ado recordset
m_pRS=NULL;
m_pRS.CreateInstance(__uuidof(Recordset));
m_pRS->CursorLocation=adUseClient;
char *table="SELECT * FROM EmployeeDetails";
m_pRS->Open(table,sConn,adOpenKeyset,adLockReadOnly , adCmdTable);
/
m_datagrid.putref_DataSource(NULL);
m_datagrid.putref_DataSource((LPUNKNOWN) m_pRS );
//m_datagrid.Refresh();
I am using Visual Studio 2008 and somehow can't make my code to open the recordset. Any help is much appreciated.
Many thanks in Advance
|
|
|
|
|
Given the complete and utter lack of error checking, the root cause could be any of the statements before the record set open call. Check the status values to see where the error actually occurs, and then ask your questions...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
my problem solved once I changed the char variable table to just EmployeeDetails but still want the ability to use select for more functionality.
Is it a little bit different in visual studio 2008.
|
|
|
|
|
I think it's the adCmdTable parameter - that says the command you're opening is a table. This page[^] documents the other options, while this page[^] suggests you want adCmdText if you want to use a SELECT statement as the command text.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I use a tab control in a dialog which is as a property setup window and put three dialogs into this tab control.Here is the problem,how can i destroy this three dialog and the mian dialog,return to the mian window.
|
|
|
|
|
If the dialog is modal, it will get destroyed when you click OK or Cancel.
"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
|
|
|
|
|
Hi!
I have an application which sits in the system tray globally listening for a combination key press event (CTRL+ALT+T). Instead of opening the app by right clicking the app icon in the tray bar (clicking Open), I would like to open the app window upon CTRL+ALT+T. When that happens, sometimes (more often than not) the window loses focus/gets inactivated and I manually need to click it to regain focus.
What else besides the following lines of code can be done to force the app foreground, topmost, focused and active?
((CMyAppDlg*) AfxGetApp()->GetMainWnd())->ShowWindow(SW_SHOW);
((CMyAppDlg*) AfxGetApp()->GetMainWnd())->SetFocus();
((CMyAppDlg*) AfxGetApp()->GetMainWnd())->SetForegroundWindow();
Thx!
/T
|
|
|
|
|
The behavior of the SetForegroundWindow Function[^] can be affected by SPI_GETFOREGROUNDLOCKTIMEOUT as described in the SystemParametersInfo Function[^]
See if this works for you:
HWND hWnd = GetForegroundWindow();
DWORD dwThread = GetCurrentThreadId();
DWORD dwProcessID = GetWindowThreadProcessId(hWnd,NULL);
if(hWnd > 0)
{
AttachThreadInput(dwProcessID,dwThread,TRUE);
(AfxGetApp()->GetMainWnd())->SetForegroundWindow();
AttachThreadInput(dwProcessID,dwThread,FALSE);
}
Best Wishes,
-David Delaune
|
|
|
|
|
Try BringWindowToTop function.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi all,
i have SDI type application,and split it in two columns.
for one column i m using a Treeview and for another one i m using a FormView.
The crash points to atlsimpstr.h line 107, trying to step through the debugger just tells me it is outside of the application, with ATLASSERT() inside CstringData in the method Release().
The debuger stops on the following "ATLASSERT()", obviously it expects nRefs to equal zero, and it is not so, but what does it refer to, I have no idea, or how do I find out either. This is inside "ATLSIMPSTR.H",
void Release() throw()
{
ATLASSERT( nRefs != 0 );
if( _AtlInterlockedDecrement( &nRefs ) <= 0 )
{
pStringMgr->Free( this );
}
}
My application's name is Test.EXE - here is the call stack dump at the point of the crash...
<br />
Test.exe!ATL::CStringData::Release() Line 107 + 0x25 bytes C++<br />
Test.exe!ATL::CSimpleStringT<wchar_t,0>::operator=(const ATL::CSimpleStringT<wchar_t,0> & strSrc="127.0.0.1") Line 300 C++<br />
Test.exe!CLeftView::ConnectNet() Line 640 + 0x2d bytes C++<br />
Test.exe!ThreadFunc(void * pT=0x01ee7d40) Line 773 C++<br />
Test.exe!_AfxThreadEntry(void * pParam=0x005eed14) Line 109 + 0xf bytes C++<br />
Test.exe!_callthreadstartex() Line 348 + 0xf bytes C<br />
Test.exe!_threadstartex(void * ptd=0x01eea230) Line 331 C<br />
kernel32.dll!760f4911() <br />
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll] <br />
ntdll.dll!775ce4b6() <br />
ntdll.dll!775ce489() <br />
<br />
Hope someone can help me out here…
thanks n regards.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
What are you doing in your CLeftView::ConnectNet function ? Show some code around the line 640, because it seems you are doing something wrong there. IT seems you are doing something wrong with a string assignement.
BTW, when you have such a crash, 99.999% of the time it means you did something wrong in your code. So, if you don't post any of the code around where the crash occurs, it's almost impossible for us to help you.
|
|
|
|
|
CString dnsbuf_str,IPdomain;
IPdomain = HostInfo(dnsbuf_str);
and
CString CLeftView::HostInfo(CString str)
{
CString str1;
struct hostent *remoteHost;
ShellExecute(NULL,_T("Open"), _T("ipconfig.exe"),_T("/flushdns"),NULL,0);
char *host_name = new char [str.GetLength()+1];
memset(host_name,0,str.GetLength()+1);
wcstombs(host_name, str, str.GetLength()+1);
struct in_addr addr;
WSADATA wsaData;
int iResult;
iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (iResult != 0)
return _T("N/A");
remoteHost = gethostbyname(host_name);
if (remoteHost == NULL)
return _T("N/A");
else
{
addr.s_addr = *(u_long *) remoteHost->h_addr_list[0];
str1=CString(inet_ntoa(addr));
return str1;
}
}
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
I asked for the CLeftView::ConnectNet method, not the HostInfo method. Could you post the correct method (and also indicate which line is the 640 line) ?
On the other hand, you have a flaw with your code: you suppose that UNICODE is always defined (because you always convert your input string to a multibyte characters string). If you later undefine UNICODE or wants to make a non-UNICODE build, your program will probably crash. Make sure you make the conversion only when unicode is enabled.
|
|
|
|
|
void CLeftView::ConnectNet(void)
{
CString server_name=mServer;
CString dnsbuf_str = dnsBuf;
IPdomain = HostInfo(dnsbuf_str);
CString hostBuf_str = hostBuf;
IPhost = HostInfo(hostBuf_str);
if(Oncef==1)
{
hostCtr=0;
Oncef++;
LPSERVER_INFO_101 pBuf = NULL;
LPSERVER_INFO_101 pTmpBuf;
DWORD dwLevel = 101;
DWORD dwPrefMaxLen = -1;
DWORD dwEntriesRead = 0;
DWORD dwTotalEntries = 0;
DWORD dwTotalCount = 0;
DWORD dwServerType = SV_TYPE_SERVER;
DWORD dwResumeHandle = 0;
NET_API_STATUS nStatus;
LPTSTR pszServerName = NULL;
DWORD i;
nStatus = NetServerEnum(NULL,dwLevel,(LPBYTE *) &pBuf,dwPrefMaxLen,&dwEntriesRead,
&dwTotalEntries,dwServerType,NULL,&dwResumeHandle);
if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
{
if ((pTmpBuf = pBuf) != NULL)
{
for (i = 0; i < dwEntriesRead; i++)
{
if (pTmpBuf == NULL)
break;
LPWSTR szSName=pTmpBuf->sv101_name;
CString szSName_str = szSName;
IPhost=HostInfo(szSName_str);
if(_tcscmp(IPdomain,IPhost) && _tcscmp(mServer,szSName)!=0)
{
hCh1=GetTreeCtrl().InsertItem(szSName,0,0,hChild3);
GetTreeCtrl().Invalidate(1);
szHostList[hostCtr]=szSName;
hostCtr++;
}
else
{
szHostList[hostCtr]=szSName;
hostCtr++;
}
pTmpBuf++;
dwTotalCount++;
}
if (nStatus == ERROR_MORE_DATA)
{
}
}
m_bEnable1=TRUE;
m_bEnable=FALSE;
}
else
{
m_bEnable=TRUE;
m_bEnable1=FALSE;
Oncef=1;
}
if (pBuf != NULL)
NetApiBufferFree(pBuf);
}
}
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
What is this HostInfo function ? I never saw that and I can't really find something usefull when googling for it. Do you have a link to the documentation ?
|
|
|
|
|
I m already define HostInfo function in my above post.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Put a breakpoint on line 640 (when you call the HostInfo function) and inspect the content of dnsbuf_str. Does it contain something valid ?
|
|
|
|
|
So which of these statements is causing the problem?
"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
|
|
|
|
|
"_$h@nky_" wrote: str1=CString(inet_ntoa(addr));
I guess this is wrong too (and that's probably your problem): if UNICODE is defined (which is what you expect apparently), you are passing a multi-byte characters string to the CString constructor and as UNICODE is defined, it is expecting a wide characters string.
I strongly suggest that you read this article[^]. All the things related to strings and unicode will be a bit clearer afterwards.
|
|
|
|