|
Are you using MFC?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
|
Then put this code in the view's OnPrepareDC() method after calling the base implementation:
if (pDC->IsPrinting() != FALSE)
{
pDC->SetMapMode(MM_ISOTROPIC);
pDC->SetWindowOrg(m_BmpInfo.bmWidth / 2, m_BmpInfo.bmHeight / 2);
pDC->SetViewportOrg(pDC->GetDeviceCaps(HORZRES) / 2, pDC->GetDeviceCaps(VERTRES) / 2);
pDC->SetWindowExt(m_BmpInfo.bmWidth, m_BmpInfo.bmHeight);
pDC->SetViewportExt(pDC->GetDeviceCaps(HORZRES), pDC->GetDeviceCaps(VERTRES));
}
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hi all,
I have created a setup for an application. When I perform an upgrade operation using this setup, currently the logon information is read from a file(setup.inf). It includes username, password, servername and database name. Now I don't want to depend on this setup.inf file. Instead at the time of upgradation, the setup should read this information from the DSN already created. If anyone knows how to do this then please tell me.
Thanking You.
Regards,
Harshad
|
|
|
|
|
System DSN are stored in the registry at HKEY_CURRENT_USER/SOFTWARE/ODBC/OBBC.INI
youc can read the DSN named key.
Ritu Kwatra
|
|
|
|
|
Hi
I have a TabCtrl. The user should finish the operation on Tab 1 (press a button in the tab 1) before being able to access Tab 2 and the others.
How can i make this restriction?
/\|-||\/|/\|)
|
|
|
|
|
hi
On button of Tab1 declare the extern global value set to specific value and on tab2 check that value if u get that allow it or else set the focus to tab1
cheers
|
|
|
|
|
I write a program,use the global msg hook.Although the wm_keydown 、wm_mousemove and other msg can hook,but the wm_destroyclipboard、WM_DRAWCLIPBOARD and other clip msg cann't hook.
Can anyone tell me why?How can i to do ? Thanks a lot!
hook = SetWindowsHookEx(
WH_GETMESSAGE,
(HOOKPROC)msghook,
hInstance,
0);
---------------------
if(code < 0)
{ /* pass it on */
CallNextHookEx(hook, code,
wParam, lParam);
return 0;
} /* pass it on */
LPMSG lpEvent = (LPMSG)lParam;
if( lpEvent->message == WM_DESTROYCLIPBOARD)
{
MessageBox(NULL,"click!","click",MB_OK);
nn=FALSE;
}
// Pass the message on to the next hook
return CallNextHookEx(hook, code,
wParam, lParam);
|
|
|
|
|
There is modal dialog and on its DoModal() we start a thread
CPBarDlg dlg;
dlg.DoModal();
BOOL CPBarDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_event = CreateEvent(0,true,false,0);
p->event = m_event;
p->quit = 0;
pTH = AfxBeginThread((AFX_THREADPROC)&annthread,p,0,0,0,0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPBarDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
p->quit = 1;
WaitForSingleObject(m_event, INFINITE); //returns when m_event in signaled state
//hang here sometimes in Release mode??????
CloseHandle(m_event);
CDialog::OnClose();
}
/////////////////////////////////////////////////////////////////////////////
//////////////////////////////THREAD/////////////////////////////////////////
UINT annthread(LPARAMS p)
{
while(!p->quit)
{
//do some calculations.... req about 10-20ms
}
SetEvent(p->event);
return 0;
}
///////////////////////////////////////////////////////////////////////////////
So in order to end thread before we close CPBarDlg we set p->quit = 1 and wait untill event signaled by thread. But it is not set in thread in Release mode and OnClose() handler start to wait forever for WaitForSingleObject(m_event, INFINITE)??? whats wrong
9ine
|
|
|
|
|
Did you declare the quit variable with the volatile modifier?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
why? no I didnt. it is just a structure
typedef struct _params
{
int quit;
HANDLE event;
...
...
etc...
}PARAMS p, LPARAMS *p;
and then just:
PARAMS p; //in dialog header file
and
p.quit = 0;
p.event = ...
... etc
beforecreating a thread and passing PARAMS to it.
9ine
|
|
|
|
|
You need to declare quit as volatile, which guarantees that the compiler won't do any optimization, which is what is happening in your case. The compiler probably decided that quit was not being modified in the while loop and decided to ignore the check altogether.
Declaring it as volatile prevents the compiler from doing that optimization, my guess is that would solve your problem.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
yes I choosed optimization in Release mode, interesting that it prevents checking variable if it is not modified in while loop ) . I noted that it is terminated about 1 to 4 not terminated cases. Will check it with volatile mod.
9ine
|
|
|
|
|
Intresting! volatile modifier does not help?
I noticed that thread accesses quit variable only after terminating of OnClose() method where quit variable modified, so what is the purpose of Events after this incident?
9ine
|
|
|
|
|
hi
Please help me.
I have implemented class in DLL(in vc++). now i want to access
that class in vb. how can i do this.
Is it possible to create instance of class in vb.
if anybody knows please tell me about this.
|
|
|
|
|
rajesh_kapure wrote:
I have implemented class in DLL(in vc++)
You mean a COM Dll. Right?
You can add a reference to your COM Dll in VB through Project->References. After that you can use the COM Dll's methods.
Steve Mayfield: "Coding in VB is like riding a tricycle...once you figured out how to peddle, its really hard to fall off."
My Articles
|
|
|
|
|
Thanks Aamir
i already done that thing.
but whenever i add a refference of COM Dll it gives message "can't add
reference to the specified file"
can you give me step or source code for how to create COM DLL in vc++.
so that i will better understand.
Rajesh
|
|
|
|
|
|
No, Can you tell me step by step how to create COM DLL.
or send me source code for that.
Rajesh
|
|
|
|
|
Hello.
I can't solve one problem.
I need on WM_KEYDOWN set focus on Edit and to add to Edit symbol,that was pressed.Also I need to save information about CapsLock and Shift.
Can anyone help me?
|
|
|
|
|
Hi,
Is there any alogrithm for conversion between UTF8 and UTF16. Need help reg this. Urgent.
Thanks
Cool Ju
|
|
|
|
|
|
Hi
I have the problem while calling webservice created in ASP.net through vc++.
Any kind of help is appreciated.
cheers
hi
|
|
|
|
|
|