|
Here is how to get ip address from system name:
|
|
|
|
|
Hi,
i need some help to solve this problem after create of worker thread.
When i create a worker thread i receive this error message:
Windows has triggered a breakpoint in myprog.exe.
This may be due to a corruption of the heap, which indicates a bug in myprog.exe or any of the DLLs it has loaded.
This is the code snippet:
CWinThread* cmythr= AfxBeginThread(controlfunc,params, THREAD_PRIORITY_HIGHEST, 0,CREATE_SUSPENDED,0);
if(NULL != cmythr)
{
cmythr->ResumeThread();
}
but after maybe 10 seconds i receive this error message:
and the debugger show in this code in the file thrdcore.cpp:
DWORD nResult = 0;
if (pThread->m_pfnThreadProc != NULL)
{
nResult = (*pThread->m_pfnThreadProc)(pThread->m_pThreadParams);
ASSERT_VALID(pThread);
}
A thing what make me confuse is that i cant find this position with memory allocation, i do nothing like this in this Function?
No parameter is NULL, what i'm doing wrong?
Any help is welcome
Thanks
bosfan
|
|
|
|
|
Answer these two questions.
1) Provide the prototype of your function controlfunc>
2) What do you pass as params?
|
|
|
|
|
It's impossible to guess what may be wrong with the information you provided. You should use your debugger to set some breakpoints in your code, and check the actual values of the various parameters at the time of the failure. You can also use the stacktrace to see which functions have been called recently.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi,
thanks for reply i try to solve this in this way.
best regards
bosfan
|
|
|
|
|
Could be wrong here but I think you have to call a Macro just after the thread enters in order to set it up properly, google it, it is well known. (Had this years ago, and havent done any user mode for ages. )
|
|
|
|
|
Try enabling the "page heap" for your application. It can be a little painful but it often finds the cause of problems like yours.
Steve
|
|
|
|
|
What are the steps required, i will connect to the SQL named instance server using the "CDatabase::OpenEx" by using the DNS Name?
i am already able to connect the SQL Server using the ip_address, Now i want to connect the SQL Server named instance by using Domain Name system name.
Can any one knows , kindly provide the solutions.
thanks,
lucky.
|
|
|
|
|
There is no difference, as long as the name can be resolved to the correct IP address.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hello Friends
I am creating a win32 based application. Creating A Dialog with TabControl and Buttons using BS_OWNERDRAW as i want to set the color of button.
On WM_DRAWITEM, I implemented a function to set the color of button[ by getting all dc and rect of button and then fillrect).
So,when I open the Dialog, it is showing Initial Color Fine.
Now,I want to change the colors of button when I change the Tab. But,I am not able to find the Event or same WM_DRAWITEM will change button color on changing tab.
So,On Tab change,button colors remain same. How can I change the button color on Tab change.
Thanks & Regards
Yogesh
|
|
|
|
|
The right message (to handle) for changing button's color is WM_CTLCOLORBTN
|
|
|
|
|
But when this message(WM_CTLCOLORBTN) will be called ?
How can I handle this ?
Need little explanation.
Thanks In Advance.
Regards
Yogesh
|
|
|
|
|
It will be sent to the parent window (in your case the dialog) just before the button is painted. So handle it in your dialog's DlgProc function by creating a brush in the background color that you want, casting it to BOOL and returning it. See MSDN for details.
http://msdn.microsoft.com/en-us/library/aa930774.aspx[^]
|
|
|
|
|
 I took HBRUSH as Global variable and then how it will be responsible for drawing all buttons and with different color.
Here is WM_DRAWITEM:
case WM_DRAWITEM:
{
LPDRAWITEMSTRUCT lpDrawItemStruct = (DRAWITEMSTRUCT*)lParam;
switch (lpDrawItemStruct->itemAction)
{
case ODA_DRAWENTIRE:
case ODA_SELECT:
{
int ndxColor = 0 ;
switch (lpDrawItemStruct->CtlID)
{
case IDC_btnPantone1 : ndxColor = 0 ; break ;
case IDC_btnPantone2 : ndxColor = 1 ; break ;
case IDC_btnPantone3 : ndxColor = 2 ; break ;
case IDC_btnPantone4 : ndxColor = 3 ; break ;
case IDC_btnPantone5 : ndxColor = 4 ; break ;
case IDC_btnPantone6 : ndxColor = 5 ; break ;
case IDC_btnPantone7 : ndxColor = 6 ; break ;
default : break ;
}
switch (lpDrawItemStruct->CtlID)
{
case IDC_btnPantone1 :
case IDC_btnPantone2 :
case IDC_btnPantone3 :
case IDC_btnPantone4 :
case IDC_btnPantone5 :
case IDC_btnPantone6 :
case IDC_btnPantone7 :
DrawButtonColor (ndxColor, lpDrawItemStruct) ;
break ;
default : break ;
}
}
default:
return DefWindowProc (hwndDlg, msg, wParam, lParam);
break;
break;
}
return TRUE;
}
case WM_CTLCOLORBTN :
{
SetBkColor((HDC)wParam, RGB(0,0,255));
return (BOOL)g_hBrush;
}
it is not changing .
Or m wrong somewhere ?
|
|
|
|
|
No need to use SetBkColor(). Windows uses the returned brush to paint the background.
Check the color used for g_hBrush.
|
|
|
|
|
void CPNGButton::OnLButtonDown(UINT nFlags, CPoint point)
{
SetCapture();
SetPNG2Button(m_strMouseDownImagePath);
CStatic::OnLButtonDown(nFlags, point);
}
void CPNGButton::OnLButtonUp(UINT nFlags, CPoint point)
{
SetPNG2Button(m_strMouseMoveImagePath);
CStatic::OnLButtonUp(nFlags, point);
}
void CPNGButton::OnMouseMove(UINT nFlags, CPoint point)
{
SetCapture();
CRect rc;
GetClientRect(rc);
if (rc.PtInRect(point))
{
if (!m_isPointInWnd)
{
OnMouseEnter();
m_isPointInWnd = TRUE;
}
}
else
{
SetPNG2Button(m_strMouseAwayImagePath);
ReleaseCapture();
m_isPointInWnd = FALSE;
}
CStatic::OnMouseMove(nFlags, point);
}
void CPNGButton::OnMouseEnter()
{
SetPNG2Button(m_strMouseMoveImagePath);
}
I create a CPNGButton class to display a button. Using three images to display three different status. No mouse, mouse move, L Button down. CPNGButton is a child class of CStatic. Now if this CPNGButton button is a Minize button, when click this button. After restore the MainFrame, how to restore the minimize button status. Just to how to capture the mouse away from this minimize button?
|
|
|
|
|
BOOL CMainFrame::Login()
{
this->ShowWindow(SW_MINIMIZE);
CLoginForm loginForm();
if (loginForm.DoModal() != IDOK)
{
this->PostMessage(WM_CLOSE);
return FALSE;
}
...
this->ShowWindow(SW_SHOWNORMAL);
return TRUE;
}
void CLoginForm::OnClickedMinimize()
{
ShowWindow(SW_MINIMIZE);
}
The MainFrame is showing and the user click the logout button to call login function. The the CLoginForm show, CLoginForm is a no border CDialog, when user click the minimize button of CLoginForm. The CLoginForm is hide, but there is a black block in the left-bottom of the screem. I donot know why this happen.
|
|
|
|
|
My guess is that login being a modal dialog will prevent the parent window from processing things (like paint messages) until the modal dialog is dismissed. Might you use a modeless dialog in this case?
|
|
|
|
|
Why, oh, Why do you want to minimize the main frame window when the Modal login dialog is displayed ?
Don't make it hard on you, just keep the main frame as is.
Nihil obstat
|
|
|
|
|
Hi all,
I'm abit of a newbie to C so what i am askign may be simple but i can't seem to find much on the internet.
i have:
char name[15];
Which could for example, contain the name "james". What can i use to check if the first character (in this case "j") is lowercase and if it is, change it to uppercase.
Many Thanks!
|
|
|
|
|
Sorry just found it myself, literally just after i posted this.
name[0] = toupper(name[0]);
|
|
|
|
|
In c language you can check wether the language is in lower case or upper case by using their ASCII value.
ie, for "A" ASCII value is 65. for "a" ASCII is 97. by directly checking this condition you can ensure character is small letter or capital letter.
to convert you can use
toupper or
tolower .
|
|
|
|
|
What happens if the letter is "b" or ... The standard way of checking is to use isupper() [^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi,
I am working on a project in which we can capture a video, save it in avi format. We are using Microsoft Directx for the same.
Now I want to increase the quality of the video similar to the HD mode. Is It possible using C++/VC++/MFC.?
Is it possible that we can capture a video with high quality or after capturing/saving the video, play the same in HD mode.?
Please let me know if the above discussion is ambiguous.
Anybody have any idea regarding the same.?
Any help would be appreciated.
Thanx in Advance.
Regards,
Mbatra
|
|
|
|
|
Hi All,
I am using below code to convert CString to char* and again back to CString. I am using 3rd party code which takes char* only.
const size_t newsizew = (str.GetLength()+1)*2;
char *nstringw = new char[newsizew];
size_t convertedCharsw = 0;
wcstombs_s(&convertedCharsw, nstringw, newsizew, str.GetBuffer(), newsizew /*_TRUNCATE*/ );
AfxMessageBox(CString(CA2T(nstringw)));
The conversion is working fine when content of str is in english. But this is not working properly when str is in other language.
Can anyone suggest me how to make it work even for other languages.
Thanks in advance.
|
|
|
|