|
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
|
|
|
|
|
Can any one plz help me to create a file IN VC++ or C++ that can be given some FILE permissions (READ for normal users).The files cannot be deleted also.
Proud To Be an India
|
|
|
|
|
Do you mean a simple text file written through VC++ / C++ code ?
If this is your requirement then try _chmod, _wchmod .
Regards,
Paresh.
|
|
|
|
|
I have a program running under USER mode - and later i have to create a file in administrator mode - setting the privilages and all...
Hope u got my requirement now..
Proud To Be an Indian
|
|
|
|
|
Try using API SetFileSecurity .
Regards,
Paresh.
|
|
|
|
|
Try also using SetNamedSecurityInfo .
Regards,
Paresh.
|
|
|
|
|
Hi,
Check with SetFileAttribute(...) Api.
It will Help You.
Uday kiran
|
|
|
|