Yes, your code is correct but important point is what you want to acheive from it. below is the c++ code for the same.
void __cdecl ThreadJob(void*);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
unsigned long ulThr1;
switch(iMsg)
{
case WM_CREATE:
ulThr1 = _beginthread(ThreadJob,0,(void*)hWnd);
break;
case WM_PAINT:
int i=0;
char str[2];
hDc=BeginPaint(hWnd,&ps);
for(i=0; i<5; i++)
{
sprintf(str,"Main Thread -> No = %d",i);
TextOut(hDc,5,5*(i*2),str,strlen(str));
}
EndPaint(hWnd,&ps);
break;
}
return DefWindowProc(hWnd,iMsg,wParam,lParam);
}
void __cdecl ThreadJob(void* param)
{
HDC hDc;
int j;
char str[2];
hDc = GetDC((HWND)param);
for(j=0; j<10; j++)
{
sprintf(str,"Other Thread -> No = %d",j);
TextOut(hDc,50,5*(j*2),str,strlen(str));
}
ReleaseDC((HWND)param,hDc);
}