|
How to use CDaoDatabase to open SQL server database?
the database is remote on the internet or local-area-network.
I need sample of connect string, eg. how to use ip-address etc in function:
CDaoDatabase::Open(LPCTSTR lpszName, BOOL bExclusive = FALSE,
BOOL bReadOnly = FALSE, LPCTSTR lpszConnect = _T(""));
any actual C++ code is help.
thx.
|
|
|
|
|
|
|
I have an EXE that has a hidden window.
Is it possible to obtain a handle to this window and post a WM_QUIT message.
The basic requirement that I have is that I need to un-install an application and before the process of un-install , I need to kill the process .
|
|
|
|
|
Something like this would work.
VOID YourClass::EnumerateWindows()
{
EnumWindows(EnumWindowsProc,0);
}
BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam)
{
DWORD dwPID = 0;
GetWindowThreadProcessId(hWnd,&dwPID);
if(dwTargetPID == dwPID)
{
if (!(GetWindowLong(hWnd,GWL_STYLE) & WS_VISIBLE))
{
::PostMessage(hWnd,WM_CLOSE,0,0);
}
}
return(TRUE);
}
|
|
|
|
|
act_x wrote: before the process of un-install , I need to kill the process .
cruel programming. 
|
|
|
|
|
Hi,
I am re-posting this because I am still having this problem and I am desperate to figure it out. I am trying to create a tray icon. I downloaded Chris Maunder's project and it works for me in my test dialog which is modal. Now I am trying to get it to work in a modeless dialog that ultimately I want to be hidden. I cannot get the tray icon create logic to work. The call to ::Shell_NotifyIcon() fails but I have no idea why. The NOTIFYICONDATA struct seems to be filled in correctly and GetLastError() returns 0. I have tried it with and without a visible modeless dialog. I need the tray icon only to let my user know that my service is running. My code is below.
I call the logic to create the icon below:
m_iconTray.Create( this, <br />
WM_ICON_NOTIFY,
_T("AutoFileHandler is running"),
::LoadIcon( NULL, IDI_ASTERISK ),
IDR_TRAYICON );
The Icon Create() logic:
m_tnd.cbSize = sizeof(NOTIFYICONDATA);<br />
m_tnd.hWnd = pParent->GetSafeHwnd()? pParent->GetSafeHwnd() : m_hWnd;<br />
m_tnd.uID = uID;<br />
m_tnd.hIcon = icon;<br />
m_tnd.uFlags = NIF_ICON | NIF_TIP;
m_tnd.uCallbackMessage = uCallbackMessage;<br />
_tcscpy(m_tnd.szTip, szToolTip);<br />
<br />
VERIFY(m_bEnabled = ::Shell_NotifyIcon(NIM_ADD, &m_tnd));
Any help appreciated
|
|
|
|
|
Is there anything on the modeless dialog? I had an interactive service that displayed a tray icon without any problem. The service called the following
CreateEx (0, AfxRegisterWndClass (0), "", WS_POPUP, 0, 0, 10, 10, NULL, 0);
m_notifyIconData.cbSize = sizeof (NOTIFYICONDATA);
m_notifyIconData.hWnd = m_hWnd;
m_notifyIconData.uID = 1;
m_notifyIconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
m_notifyIconData.uCallbackMessage = WM_APP;
m_notifyIconData.hIcon = ::LoadIcon (AfxGetResourceHandle (),
MAKEINTRESOURCE (IDI_ICONTRAY));
m_notifyIconData.uVersion = NOTIFYICON_VERSION;
strcpy_s (m_notifyIconData.szTip, 64, "Service Name");
Shell_NotifyIcon (NIM_ADD, &m_notifyIconData);
where m_hWnd was returned by the CreateEx call.
The service regularly called a message pump on the m_hWnd
MSG msg;
while (PeekMessage (&msg, NULL, 0 ,0, PM_REMOVE))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
The window procedure for the m_hWnd received WM_ messages so I could process a double click and the right-click.
NOTE - my responsiveness to answer any questions about this will be really bad this weekend since I have lots of time-consuming plans. Good luck
Judy
|
|
|
|
|
In addition to Judy's reply...
Have you checked all the relevant members of the NOTIFYICONDATA struct?
With a breapoint on the Shell_NotifyIcon() call, what are the values of the hWnd, hIcon, uID, and szTip members?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The struct values are:
hWnd = 0x001A0230
hIcon = 0x0001000b
uID = 107
szTip = "AutoFileHandler is running"
The window has a static control and a button on it. More tomorrow.
|
|
|
|
|
hmm... Are you doing this from a service or is it not working in a regular app?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have it working in dialog app, but I need to get it working in my service app.
|
|
|
|
|
Ok now that I'm caught up...
Have you done everything required here[^]?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hy there!
i have a hughe problem in my company. i have a quite complex application (distributed, corba, mulithreaded, Boost, QT 3.3)
and after closing the program (int closeevent() pApp->exit())
the program closes but after ca 5 sec. there comes an ASSERTION
attached_thread_count == 0
in tss_hooks.cpp
the code in boost looks like that:
attached_threadcount == 0 in tss_hooks.cpp. the code there looks like this:
it is in on_process_exit()..
catch( ... )
{
boost::call_once(init_threadmon_mutex, once_init_threadmon_mutex);
boost::mutex::scoped_lock lock(*threadmon_mutex);
BOOST_ASSERT(attached_thread_count == 0);
return -1;
even with the help of some c++ gurus and DevPartnerStudio we could not find the problem.
actually it isnt that annoying because only at exit it happens. but we cant deliver it to the customer like that.
does enyone has an idea what to do against it, even a trick to just dont show the assertion?
unfortunately i cant make a release-version for different reasons.
ideas? suggestions??
thanx for any input!!
p.s. someone gave me the following input in an other board:
Anyway, the assertion comes from the thread_specific_ptr machinery. It means that something registered a thread-exit handler but it wasn't called. This might happen if, for example, you use a thread_specific_ptr from a thread that wasn't created with boost::threads.
andreas
|
|
|
|
|
The problem isn't the ASSERT but what thread is not terminated. It's the 1st priority to check which thread and what line in the thread is still busy when the exit signal has been fired.
And why does it enter the catch block?! What throws?
Maxwell Chen
|
|
|
|
|
andreas.schaerer wrote: even a trick to just dont show the assertion?
abort[^] should do the trick, but I would ask the question on a Boost mailing list to properly fix the problem.
|
|
|
|
|
I am trying to play a AVI file on status bar indicating the progress for the lengthy operation.
I am doing this in a button click event. it is working fine if no statements are there below the call and, if there are statements below the avi start.. the avi is not playing on status bar.
I tryed with thread, but of no use.
void TestPb::OnButton1()
{
CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
pFrame->StartAnimation( IDR_AVITEST ,1);
whie(1)//Say length process.... If i comment while(1) .. avi is playing on mainfram status bar
{}
}
|
|
|
|
|
you should move the portion of code playing the AVI in its own thread... and start the thread on the trigger of your choice.
|
|
|
|
|
I tried placing in threaed but failed
|
|
|
|
|
ptr_Electron wrote: I tried placing in threaed but failed
how did you do that ?
|
|
|
|
|
super_ttd wrote: how did you do that ?
Oh it's easy, you just do something or other
led mike
|
|
|
|
|
Hi,
Its hard to give you advice without seeing what type of 'processing' you are doing. You should avoid drawing on a window from a separate thread if at all possible. You may be able to simply pump the message que and move the AVI-frame painting into OnPaint.
In the while loop you can probably add:
while(somecondition)
{
MSG oMSG;
while(::PeekMessage(&oMSG, NULL, 0, 0, PM_NOREMOVE))
{
if(::GetMessage(&oMSG, NULL, 0, 0))
{
::TranslateMessage(&oMSG);
::DispatchMessage(&oMSG);
}
else
{
break;
}
}
}
pre>
This will allow the dialog to process WM_PAINT messages normally.
|
|
|
|
|
you certainly didn't want to say that to our great toxcct, did you ?
|
|
|
|
|
oops!

|
|
|
|
|
Thanks you very much, for your help, what I am trying to do is extrading 1000's of records from database. since it takes quite some time I want play the avi file on the status bar of main frame,
but the call will be made from the dialg. say on button click event we are extracting records form DB and need progress on the status bar, but does not work...
void TestPb::OnButton1()
{
thpbar=AfxBeginThread(thPrgbar,THREAD_PRIORITY_NORMAL,0,0,NULL);
//Get 1000's records from DB ..verytime consumming process...
}
UINT TestPb::thPrgbar( LPVOID pParam )
{
CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
pFrame->StartAnimation( IDR_AVITEST ,1);
return (1);
}
void CMainFrame::StartAnimation( UINT id, int nPane /*=1*/ )
{
StopAnimation();
m_pAnimate = new CStatusbarAnimate;
m_pAnimate->Create(id, nPane);
}
void CMainFrame::StopAnimation()
{
delete m_pAnimate;
m_pAnimate = NULL;
}
bool CMainFrame::IsAnimationActive()
{
return (m_pAnimate != NULL);
}
// needed to ensure original text not visible
void CMainFrame::OnUpdateAnimate(CCmdUI* pCmdUI)
{
pCmdUI->SetText(_T(""));
}
|
|
|
|