|
Hi all.
I am converting my old project developed in VC 6.0 to VS 2005. But the new project is failed to create the .lib file in VS2005 which causing error while using that project in others. Please help me if any one knows the solution.
Kishore.
|
|
|
|
|
|
Not showing any error. I want to create a .dll file; and .lib file is also needed. whereas it is able to create the .lib file only when the configuration type is set to .lib file where as i need both .dll and .lib files.
But the same is working fine in another project for which the configuration type is to create .dll; it is making both dll and lib files.
I have tallied all the settings of both projects but it is successful for only that project. All others are not able to create .lib and .dll at a time.
I dont know how only one project is creating both successfully and all others are not able to do that.
Kishore.
|
|
|
|
|
Hi,
I have some PNG files, which are not displaying properly in my application control, while they are opening perfectly fine in the browser.
some of the files , which is creating problem have the foll. info..
Bit depth - 24
Width - 96 pixels
Height - 96 pixels
Horizontal Resolution - 96 dpi
Vertical Resolution - 96 dpi
some files, which are opening properly have the foll. info..
Bit depth - 24
Width - 48 pixels
Height - 48 pixels
Horizontal Resolution - 96 dpi
Vertical Resolution - 96 dpi
i tried to use the libpng, to convert the files, in to the dimension , which is converting properly..but could not found the solution.
Can u pl. suggest something.. how to display them properly or what API should I use for the conversion.
Thanks.
Vineet Kumar Singhal
Sr.Software Engineer
Mumbai
Tough Time Never last, but Tough People do.
|
|
|
|
|
Could you please tell, what do you mean by "Not Diplaying properly",
are they distort, not seen, or partially seen ?
Regards,
Paresh.
|
|
|
|
|
here I mean that the images are distorted.if i open it with "Windows Picture and Fax Viewer" it shows distorted.
if I open it on a web control /ACDsee, it opens perfectly fine.
I am displaying at 2 locations.. at the lacation where web control is opening it, it works fine.., while for the second control, which is a static image control,is displaying it distorted.
Regs
Vineet Kumar Singhal
Sr.Software Engineer
Mumbai
Tough Time Never last, but Tough People do.
|
|
|
|
|
Hope I understood your question
if you want to detaily of image(png) you can use of CImage class
|
|
|
|
|
Try using GDI+ , it can load png files.
If u can Dream... U can do it
|
|
|
|
|
Hi All,
I need to write some ActiveX control that will help me to define some Tree control that have Header.
I already write some class that do it - ( i mean that if i create in MFC application some dialog with CTreeCtrl and i Replace this control with the control that i wrote then i getting what i need ) - but my problem is that i don't know how to implement this in writing an ActiveX.
Some one can help me ?
I need to understand how to write ActiveX control with C++ ( i looked in the example in this site ... i did not find anything like i doing ).
Thanks for any help.
|
|
|
|
|
Seems you have no specific problem but your problem is in making a control class an ActiveX control. Then you need to know how to turn your regular C++ functions into ActiveX methods and/or properties, and this is all. So try to find any tutorial on ActiveX controls and it should help.
--
=====
Arman
|
|
|
|
|
|
hi,
I need to create an UI-thread. The main task of this thread is to perform an infinite loop that do the sending/receiving data. This thread must be able to receive message from Main thread to change behaviour.
I try to put the loop in CMyThread::Run() and put the PeekMessage also in the loop but it doesn't work. I don't know how to do it.
int CMyThread::Run()
{
for (;;)
{
DoMyWork();
if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE )!=0) // my UI thread has no window
{ TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return CWinThread::Run();
}
|
|
|
|
|
GameProfessor wrote: I need to create an UI-thread. The main task of this thread is to perform an infinite loop that do the sending/receiving data.
If the thread spends its time in an "infinite loop that do the sending/receiving data" it sounds like you're after a worker thread and not a UI thread; in which case a message pump may not be needed.
Steve
|
|
|
|
|
GameProfessor wrote: if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE )!=0) // my UI thread has no window
{ TranslateMessage(&msg);
DispatchMessage(&msg);
}
This code should look like this:
while ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Your code continually dispatches the same message forever since you're using the PM_NOREMOVE flag. I also use while instead of if : do some work, process all outstanding messages then repeat.
Steve
|
|
|
|
|
It doesn't work.
I defined my message handler using ON_THREAD_MESSAG macro.
And it seems that I must left the CMyThread::Run intact then these message handler can work. How can I have my thread keep on running my send/recv loop while still be able to handle message from the main thread ?
|
|
|
|
|
I think that you also introduce atleast a Sleep(0) after the DispatchMessage statement.
|
|
|
|
|
What for? It will not help.
Steve
|
|
|
|
|
It still doesn't work.
Actually, can DispatchMessage() work with a message handler defined using macro ON_THREAD_MESSAGE ?
|
|
|
|
|
|
That's because by implementing your own message pump instead of using CWinThread ’s you’re bypassing MFC’s message routing architecture. There are always such dangers when mixing low-level code (Win32 calls) and high-level code (MFC’s CWinThread ) without understanding how they relate to each other.
To do what you’re trying to do within the MFC architecture proceed as follows:
1. Override your CMyThread 's OnIdle member function. It should look like this:
BOOL CMyThread::OnIdle(LONG lCount)
{
DoMyWork();
CWinThread::OnIdle(lCount);
return TRUE;
}
2. Remove your CMyThread::Run override.
Steve
|
|
|
|
|
this doesn't work because things in OnIdle() can not be a loop and the framework doesn't loop that function by itself. I need an infinite loop. I have try these two methods:
Method 1: --> my thread can not handle any message from main thread
BOOL CMyThread::OnIdle(LONG lCount)
{
for(;;)
{
DoMyWork();
}
CWinThread::OnIdle(lCount);
return TRUE;
}
Method 2: --> DoMyWork() only run one time after we send message from Main thread to My thread.
BOOL CMyThread::OnIdle(LONG lCount)
{
DoMyWork();
CWinThread::OnIdle(lCount);
return TRUE;
}
I expect DoMyWork() to be loop to run forever !!! There must be a way, isn't it?
|
|
|
|
|
GameProfessor wrote: this doesn't work because things in OnIdle() can not be a loop
It will work: the loop is within MFC's CWinThread::Run function. There should be ***NO*** loop inside OnIdle ! Try it and see. Remember to remove your Run override.
Steve
|
|
|
|
|
i'm sure it wont run because it's the first thing I've tried. !!!
Here's the code:
LRESULT CMyThread::OnMyMsg(WPARAM wParam, LPARAM lParam)
{
MessageBox(NULL,"super man","MyMSG message",MB_OK); // this never show up!!!
return 0;
}
int CMyThread::Run()
{ for (;;)
{
i++;
if (i>=10000)
{
i = 0;
}
}
return CWinThread::Run();
}
BOOL CMyThread::OnIdle(LONG lCount)
{
// TODO: Add your specialized code here and/or call the base class
return CWinThread::OnIdle(lCount);
}
|
|
|
|
|
I know it will; I've just build a test app from scratch and it does. So just try it ok!
Here's code snippits:
---------------------
// From CMyThead's implementation:
BEGIN_MESSAGE_MAP(CMyThread, CWinThread)
//{{AFX_MSG_MAP(CMyThread)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
ON_THREAD_MESSAGE(WM_USER, OnFromUI) // *******IMPORTANT*******
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyThread message handlers
BOOL CMyThread::OnIdle(LONG lCount)
{
DoMyWork(); // *******IMPORTANT*******
CWinThread::OnIdle(lCount); // *******IMPORTANT*******
return TRUE; // *******IMPORTANT*******
}
void CMyThread::DoMyWork()
{
}
afx_msg LRESULT CMyThread::OnFromUI(WPARAM, LPARAM)
{
return 0;
}
// Creating the thead and a dialog:
BOOL CWillWorkApp::InitInstance()
{
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
CWinThread *pThread = AfxBeginThread(RUNTIME_CLASS(CMyThread));
CWillWorkDlg dlg(pThread);
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
// In the dialog:
CWillWorkDlg::CWillWorkDlg(CWinThread *pThread, CWnd* pParent /*=NULL*/)
: CDialog(CWillWorkDlg::IDD, pParent)
, m_pThread(pThread) // *******IMPORTANT*******
{
//{{AFX_DATA_INIT(CWillWorkDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CWillWorkDlg::OnButton1()
{
m_pThread->PostThreadMessage(WM_USER, 0, 0); // *******IMPORTANT*******
}
===========================
CMyThread::DoMyWork() is called continuously and CMyThread::OnFromUI is called when I press a button from a dialog in the main thread (not CMyThread).
Steve
|
|
|
|
|
The reason your code doesn't work is that you haven't removed your Run override as I instructed. MFC's message pump is in CWinThread::Run but your override (CMyThread::Run ) never calls it because it enters an endless loop and the call to MFC's is after it. Remove your Run function entirely.
Steve
|
|
|
|