|
kiranin wrote: I have many controls in it...
On the parent or child?
kiranin wrote: even if i didnot select it...
Select what?
kiranin wrote: How can i restrict a control to be active untill we click on it.
You want a control to be "active" until you click on it?
"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
|
|
|
|
|
What control and where can you more explain?
|
|
|
|
|
Hi all,
does anybody know about a sample using the theme api to create custom caption bar buttons?
I've tried to improve some of the themeapi samples, but I'm stuck with
GetThemeFilename - GetThemeBitmap
jung-kreidler
|
|
|
|
|
Code snippet
HMODULE m_themeLib = LoadLibrary(_T("UxTheme.dll"));
if(m_themeLib != NULL)
{
HANDLE (__stdcall *pFNOPENTHEMEDATA)(HWND hwnd, LPCWSTR pszClassList);
HRESULT(__stdcall *pDrawThemeBackground)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const RECT *pClipRect);
HRESULT (__stdcall *pFNCLOSETHEMEDATA)(HANDLE hTheme);
(FARPROC&)pFNOPENTHEMEDATA = GetProcAddress(m_themeLib, "OpenThemeData");
HANDLE hTheme = 0;
if(pFNOPENTHEMEDATA)
hTheme = (pFNOPENTHEMEDATA)(wnd.m_hWnd, L"Window");
(FARPROC&)pDrawThemeBackground = GetProcAddress(m_themeLib, "DrawThemeBackground");
rc.left += 2;
(pDrawThemeBackground)(hTheme, dc, WP_CLOSEBUTTON, CBS_NORMAL, &rc, 0);
(pDrawThemeBackground)(hTheme, dc, WP_HELPBUTTON, HBS_NORMAL, &rc, 0);
if(hTheme)
{
(FARPROC&)pFNCLOSETHEMEDATA = GetProcAddress(m_themeLib, "CloseThemeData");
if(pFNCLOSETHEMEDATA)
(pFNCLOSETHEMEDATA)(hTheme);
}
if(m_themeLib)
FreeLibrary(m_themeLib);
Regards,
Paresh.
|
|
|
|
|
when i made a connection of vc++ with mysql i got an exception
i try to solve it but not succeed
exception is
First-chance exception in company.exe (LIBMYSQL.DLL): 0xC0000005: Access Violation.
pplease solve this
hi
|
|
|
|
|
Use your debugger to track down the problem. You're probably writing to an invalid pointer.
paras_s12 wrote: pplease solve this
Giving the poor information you give, that will be really hard.
|
|
|
|
|
thanks a lot sir
my code is this
i use debugger but i can not find sloution sir
void CCompanyDlg::OnConnect()
{
int i;
MYSQL *myDB;
MYSQL_RES *res;
MYSQL_ROW row;
CString user,pass,aqp;
if ((myDB = mysql_init((MYSQL*) 0)) &&
mysql_real_connect(myDB,"localhost","root",NULL,NULL,3306,NULL,NULL))
{
if ( mysql_select_db( myDB,"gourav") < 0 )
{
MessageBox("Can't select the database !\nTry later.");
goto exit_here;
}
else
{
MessageBox("Can't connect !\nPlease try later.") ;
goto exit_here;
}
}
GetDlgItemText(IDC_USER,user);
GetDlgItemText(IDC_PASS,pass);
if(!mysql_query(myDB,"SELECT id from login WHERE user= \'" + user + "\' "))
res=mysql_store_result(myDB);
row = mysql_fetch_row(res);
{
i = (int) mysql_num_rows( res );
if (i != 1)
{
MessageBox("WRONG LOGIN PLEASE TRY AGAIN", " aq ",MB_ICONASTERISK);
mysql_free_result( res ) ;
goto exit_here;
}
}
switch(atoi(*row))
{
case 0: // regular user
{
CAdmin dlg;
dlg.DoModal();
UpdateData(FALSE);
}
break;
case 1: // administrator
{
CManager dlg1;
dlg1.DoModal();
UpdateData(FALSE);
}
break;
}
exit_here:
mysql_close( myDB);
}
hi
|
|
|
|
|
Where does it crashes ? If the debugger doesn't show your code, use the callstack to locate the problem more precisely.
|
|
|
|
|
when i use debugger then it will not show error in code
and in stack it show libmysql.dll with some no and nothing else sir
thanks
hi
|
|
|
|
|
set a breakpoint an watch your variables...
if you use/pass a null pointer, that's probably a thing to investigate...
|
|
|
|
|
Well, you could at least read what I've posted:
If the debugger doesn't show your code, use the callstack to locate the problem more precisely.
|
|
|
|
|
thanks 100 times sir
aqp ="SELECT id from login WHERE user= \'" + user + "\' ";
this query does not return value to aqp
i dont know why
can u tell me please
bye
hi
|
|
|
|
|
I really don't see how it make your application crash !
Did you do what I asked ? Meaning start your debugger, look at the call stack to see where exactly in your code the problem comes from. Then, at this point you can watch the different variables and see if they are what you expect them to be. You can also put breakpoints before and check step by step if everything goes as expected.
|
|
|
|
|
posting a huge code, not even formatted will certainly not help you but will give people a bad thinking of you.
Cédric Moonen told you to use your debugger... did you try even to ?
|
|
|
|
|
paras_s12 wrote: i use debugger...
How exactly? Did you single-step through this code snippet?
"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 there any method known which can list all directories from an filepath.
E.g.
c:\dir1\dir2\dir3\name.abc -> directories are: dir1, dir2 and dir3?
Anything, using loops or something else?
Thanks for help!
|
|
|
|
|
Call FindFirstFile with c:\dir1\dir2\dir3\name.abc and an empty WIN32_FIND_DATA variable as parameter. Your WIN32_FIND_DATA variable.cFileName will give you the first matching file name. Then you can call FindNextFile in a while loop for subsequent matches. Use the same WIN32_FIND_DATA variable as a parameter to FindNextFile . (Looping through FindNextFile is required if you are searching using wildcards, like C:\Temp\*.*)
Refer http://msdn2.microsoft.com/en-us/library/aa365200.aspx[^] for complete example.
One more thing to take care, if you search for *.*, then the first two matches will be . and .. respectively, so you may choose to ignore them.
It's better to know some of the questions than all of the answers.
Pravin.
|
|
|
|
|
You'll want to use PathFindNextComponent() .
"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
|
|
|
|
|
See DlgDirList does any help?
|
|
|
|
|
Hi everyone,
When I use Instance Subclassing technique, SetWindowLong() or SetWindowLongPtr() returns NULL pointer. The last error is 50 ERROR_NOT_SUPPORT. I ran the same program on more than 10 XP machines. One of them failed. Does anybody here encounter such problem? Any suggestion?
Thank you in advanced
|
|
|
|
|
From the SetWindowLongPtr documentation:
"If the previous value is zero and the function succeeds, the return value is zero, but the function does not clear the last error information. To determine success or failure, clear the last error information by calling SetLastError(0), then call SetWindowLongPtr. Function failure will be indicated by a return value of zero and a GetLastError result that is nonzero."
The only cases in which these functions should fail are if you pass an invalid window handle, or if you pass an invalid index value (more than the number of bytes associated with the window, or not one of the defined GWL/GWLP values).
|
|
|
|
|
Hi!
Good day
I have this problem about synchronization on namedpipe ...
I have this namedpipe server that allows multiple instances.
The algorithm I have is I'll wait for a client to connect to the namedpipe then spawn a thread which will read the message from the namedpipe. My expectation on the spawned thread is that when the client has disconnected the spawned thread will end also. But when I tried testing my code, the thread count keeps on increasing due to the spawned thread, which i think means I was not able to detect that the client had disconnected or something else
Any help is greatly appreciated.
Below are my codes:
1. Createnamedpipe, wait for a client to connect, and spawned a thread.
<br />
UINT fnRcvMsgsFrmNamedpipeThread(LPVOID pParam)<br />
{<br />
<br />
DWORD dwResult = SUCCEED; <br />
CString strLog( _T( "" ) );<br />
<br />
OVERLAPPED stClientConnectOverLap = {0};<br />
stClientConnectOverLap.hEvent = CreateEvent(<br />
NULL,
TRUE,
FALSE,
NULL);
<br />
if( stClientConnectOverLap.hEvent == NULL )<br />
{<br />
return 0;<br />
}<br />
<br />
HANDLE hEvents;<br />
hEvents = stClientConnectOverLap.hEvent;<br />
<br />
CString strFormatPipeName( _T( "" ) );<br />
strFormatPipeName.Format( "\\\\%s\pipe\mypipename", STR_PERIOD );<br />
<br />
HANDLE hClientReqPipe;<br />
<br />
while ( TRUE )<br />
{<br />
hClientReqPipe = CreateNamedPipe( strFormatPipeName,<br />
FILE_FLAG_OVERLAPPED | PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,<br />
PIPE_UNLIMITED_INSTANCES, <br />
0, 0, 10000, NULL ); <br />
if( hClientReqPipe == INVALID_HANDLE_VALUE )<br />
{ <br />
dwResult = GetLastError();<br />
break;<br />
}<br />
<br />
if( !ConnectNamedPipe( hClientReqPipe, &stClientConnectOverLap ) )<br />
{<br />
if( GetLastError() != ERROR_PIPE_CONNECTED )<br />
{<br />
DWORD dwRet = WaitForSingleObject( hEvents, INFINITE );<br />
if( dwRet != WAIT_OBJECT_0 )<br />
{<br />
dwResult = GetLastError();<br />
break;<br />
}<br />
}<br />
<br />
}<br />
CWinThread *pReadMsgThread = AfxBeginThread( fnReadMsgFrmNamedpipe, (LPVOID) hClientReqPipe );<br />
if( NULL == pReadMsgThread )<br />
{<br />
break;<br />
}<br />
<br />
}<br />
<br />
::CloseHandle( hClientReqPipe );<br />
::CloseHandle( stClientConnectOverLap.hEvent );<br />
<br />
return dwResult;<br />
}<br />
2. Spawned thread
<br />
UINT fnReadMsgFrmNamedpipe(LPVOID pParam)<br />
{ <br />
I32L dwResult = SUCCEED; <br />
CString strLog( _T("") );<br />
HANDLE hClientReqPipe = (HANDLE) pParam;<br />
<br />
OVERLAPPED stClientRecOverLap = {0};<br />
<br />
stClientRecOverLap.hEvent = CreateEvent( NULL,
TRUE,
FALSE,
NULL );
<br />
if( stClientRecOverLap.hEvent == NULL )<br />
{<br />
return 0;<br />
}<br />
<br />
HANDLE hEvents;<br />
hEvents = stClientRecOverLap.hEvent;<br />
<br />
DWORD dwTotalByte, dwRead, dwRet;<br />
<br />
while ( TRUE )<br />
{ <br />
dwTotalByte = 0;<br />
dwRead = 0;<br />
<br />
ReadFile( hClientReqPipe, NULL, 0, &dwRead, &stClientRecOverLap );<br />
dwRet = WaitForSingleObject( hEvents, INFINITE );<br />
<br />
if( dwRet != WAIT_OBJECT_0 )<br />
{<br />
dwResult = GetLastError();<br />
break;<br />
}<br />
if( !PeekNamedPipe( hClientReqPipe, NULL, 0, NULL, &dwTotalByte, NULL ) )<br />
{<br />
dwResult = GetLastError();<br />
break;<br />
}<br />
<br />
if( dwTotalByte > 0 )<br />
{<br />
char* pBuffer = new char[ dwTotalByte + 1 ];<br />
if( !pBuffer )<br />
{<br />
continue; <br />
}<br />
::ZeroMemory( pBuffer, dwTotalByte + 1 );<br />
<br />
ReadFile( hClientReqPipe, pBuffer, dwTotalByte, &dwRead, &stClientRecOverLap );<br />
dwRet = WaitForSingleObject( stClientRecOverLap.hEvent, 10000 );<br />
if( dwRet != WAIT_OBJECT_0 )<br />
{<br />
dwResult = GetLastError();<br />
break;<br />
}<br />
<br />
delete pBuffer;<br />
<br />
}<br />
}<br />
<br />
DisconnectNamedPipe( hClientReqPipe );<br />
CloseHandle( stClientRecOverLap.hEvent );<br />
return dwResult;<br />
}<br />
3. Namedpipe Client
<br />
BOOL fnNewConnectNamedPipe(LPCTSTR lpczPipeName)<br />
{<br />
HANDLE hPipe; <br />
<br />
while (TRUE)<br />
{<br />
hPipe = CreateFile( <br />
lpczPipeName,
GENERIC_READ |
GENERIC_WRITE, <br />
0,
NULL,
OPEN_EXISTING,
0,
NULL);
<br />
<br />
if (hPipe != INVALID_HANDLE_VALUE) <br />
break; <br />
<br />
<br />
if (GetLastError() != ERROR_PIPE_BUSY) <br />
{<br />
printf("Could not open pipe"); <br />
return FALSE;<br />
}<br />
<br />
if ( !WaitNamedPipe(lpczPipeName, 20000) ) <br />
{ <br />
printf("Could not open pipe"); <br />
return FALSE;<br />
} <br />
} <br />
<br />
DWORD dwBytesWritten = 0; <br />
DWORD dwBytesWrite = m_strMsgText.GetLength();<br />
DWORD dwRet;<br />
<br />
OVERLAPPED WriteOverLap = {0};<br />
WriteOverLap.hEvent = CreateEvent(<br />
NULL,
TRUE,
FALSE,
NULL);
<br />
HANDLE hEvent;<br />
hEvent = WriteOverLap.hEvent;<br />
if( !WriteFile(hPipe, m_strMsgText, dwBytesWrite + 1, &dwBytesWritten, &WriteOverLap) )<br />
{<br />
if (GetLastError() == ERROR_IO_PENDING)<br />
{<br />
dwRet = WaitForSingleObject(WriteOverLap.hEvent, 10000);<br />
if (dwRet != WAIT_OBJECT_0)
{<br />
CloseHandle(WriteOverLap.hEvent);<br />
CloseHandle(hPipe);<br />
hPipe = NULL;<br />
return FALSE;<br />
}<br />
}<br />
else <br />
{<br />
CloseHandle(WriteOverLap.hEvent); <br />
CloseHandle(hPipe);<br />
hPipe = NULL;<br />
return FALSE;<br />
}<br />
}<br />
<br />
CloseHandle(WriteOverLap.hEvent); <br />
CloseHandle(hPipe);<br />
hPipe = NULL;<br />
<br />
return TRUE; <br />
}<br />
|
|
|
|
|
Have you tried putting a breakpoint (or several) in the thread proc and watching what is
happening?
The debugger is your friend!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
hi mark,
yup I already did that ...
the funny thing is that the spawned thread is terminating when I run it with breakpoints
and when I put messageboxes.
|
|
|
|
|
After OnInitDialog()of Dialog-based applications, how the dialog is getting the message from Windows. Is the dialog polling or by wake up?
Best Regards,
Suman
|
|
|
|
|