|
Thanks Guys For Your reply.
I got the solution but in another way.I changed the last parameter of Bitblt to SRCAND which merges two colors.
Now,the prob is when I draw stripes OnPaint function is calling which hides my background image.So what can i do to keep my image there as background permanently?
Thanks In Advance.
Regards
Yogesh
|
|
|
|
|
OnPaint method always redraw window.
Does you load background image in OnPaint Method?
check with InvalidateRect API.
|
|
|
|
|
Yes,Background iMage is loading on OnPaint.
If I Load once on some other button then also it is coming but as i do some other Functionality like zoom,Draw stripes then tht Image gets hide bcoz on these functionalities OnPaint is calling.
Is there any other solution?
Thanks & Regards
Yogesh
|
|
|
|
|
show me your OnPaint code
|
|
|
|
|
Hello,
do suppose I create a thread with the following:
CWinThread* m_pThread = AfxBeginThread ((AFX_THREADPROC) ThreadFunc, this,
THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
and that I embed this in a class. Say in the methos "Start".
Then...
1. If the class is instantiated onto the stack no problem whatsoever,
otherwise
2. if the class is instantiated onto the heap I get memory leaks after
destruction of the object.
Question is the following: do I should delete explicitely the "m_pThread"
object returned by AfxBeginThread after the thread ends ?
Where do come from the thread related memory leaks I met ?
Anyone has already encountered / solved this problem ?
Cheers
Federico
|
|
|
|
|
If you have to explicitly delete the returned m_pThread depends on the m_bAutoDelete member of that CWinThread object: if the variable is set to TRUE , the object automatically deletes itself when the thread execution terminates (I'm not very sure, but I remember that this is the default).
|
|
|
|
|
I was thinking along the same lines, the fact is I got
memory leaks when and only when I instantiate objects
on the heap that start threads, the class interface
is the following:
#ifndef CONSUMER_H
#define CONSUMER_H
#include <afx.h>
#include <afxwin.h>
#include <set>
using namespace std;
typedef set<CWnd*> ObserverListConsumerDef;
#include "ThreadMessages.h"
class CConsumer
{
public:
CConsumer(void);
virtual ~CConsumer(void);
public:
bool Start(void);
bool Stop (void) { m_bStop = true; return true; }
bool Abort(void);
bool WaitForThread(DWORD dwWait);
bool IsRunning() { return m_bIsRunning; };
bool IsSuccess() { return m_bSuccess; };
virtual bool Execute() = 0;
protected:
static UINT ThreadFunc(LPVOID pVoid)
{
return( ((CConsumer*) pVoid)->LocalThreadFunc() );
}
UINT LocalThreadFunc(void);
bool m_bIsRunning;
bool m_bSuccess;
bool m_bStop;
CWinThread* m_pThread;
HANDLE m_hThread;
public:
void SetObserver(CWnd *pWnd);
void DelObserver(CWnd *pWnd);
protected:
ObserverListConsumerDef m_ObserverList;
void SendMessageToObs(UINT nMsg, WPARAM wP, LPARAM lP);
};
#endif // ! defined (CONSUMER_H)
|
|
|
|
|
When the thread ends, the CWinThread could be automatically deleted (depending on its m_bAutoDelete member), but the object of CConsumer class that you have dinamically allocated, should be deleted; you can explicitly test for the thread termination and delete the object, or make it auto-delete.
- explicitly delete the object:
CConsumer pConsumer = new CConsumer;
...
if (!pConsumer->IsRunning())
delete pConsumer; - add auto-delete feature to
CConsumer :
class CConsumer
{
...
protected:
static UINT ThreadFunc(LPVOID pVoid)
{
CConsumer* pConsumer = (CConsumer*)pVoid;
UINT retVal = pConsumer->LocalThreadFunc();
if (pConsumer->m_bAutoDelete)
delete pConsumer;
return retVal;
}
BOOL m_bAutoDelete;
...
};
|
|
|
|
|
Thanks, but I'm already deleting CConsumer objects from the heap
when the thread ends. The point is still I've got some memory leaks
related to the threads... i.e. <strcore> stuff.
I cannot understand these leaks, as I memory manage the CConsumer
objects in a proper way !
Cheers
|
|
|
|
|
Unfortunately, memory leaks are one of the hardest problems to investigate and the support given by Visual C++ to identify and fix them is not so good.
Personally, I had a try to Bounds Checker (you can get a trial version from here[^]) and I think that it's a great product: when you start a debug session, it instruments all of your executables (exe, dll, etc.) and keep trace of almost everything (memory allocations, handles, GDI resources, etc.). Finally, when you close the application it gives you a report with all the found issues: for example for each memory leak it give you a lot of informations, and it's able to point out the line in your source code where the memory was been allocated.
Hope this could help...
Cheers
|
|
|
|
|
hello guys... i have two projects. i copied all the files(*.cpp and *.h) of Proj1 into Proj2 and added them into Proj2 by right clicking "Source Files" and from the popup menu select Add->Existing Item. But compiler complains that "header.h" is not included, but it is included (in the "Header Files"). whats wrong im doing? thnx
|
|
|
|
|
overloaded Name wrote: But compiler complains that "header.h" is not included, but it is included (in the "Header Files")
What is the exact error message ?
anyway, it's not because the file is visible in the "Header Files" folder of your project that your compiler can find it. It should be either located in the same directory than the cpp file that is including it or located in a folder which is known by the compiler (that's usually what is done with header files). In your project properties -> "C/C++" -> "General" you have to add the include directories in "Additional Include Directories".
|
|
|
|
|
I need to programatically give write-access to a file that is created by my program (which runs from an administrator account) to all users. How can I set the access-control lists for a file? I'm using CreateFile to create the file.
[Edit]
I'm talking about doing the equivalent of 'chmod a+w' to a file. How can I do that on Windows? I know NT has file permissions called ACL. Is this the way to do it?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
modified on Thursday, October 21, 2010 4:49 AM
|
|
|
|
|
|
Hello,
I can create a Status Bar with initial Pane Text displayed on it. I can set the width of each pane and it can work.
The issues I am facing are :
1) The tool tips does not shows. How to display the tool tips?
2) How to set the delay time for the tool tips?
3) I can set the Pane Text and it shows. But, when I dynamically change the Pane Text from time to time, it raises error. How to dynamically change the Pane Text?
<br />
CStatusBar m_wndStatusBar;<br />
<br />
static UINT indicators[] =<br />
{<br />
ID_SEPARATOR,<br />
ID_INDICATOR_REC,<br />
ID_INDICATOR_CAPS,<br />
ID_INDICATOR_NUM,<br />
ID_INDICATOR_SCRL,<br />
};<br />
<br />
if (!m_wndStatusBar.CreateEx(this, SBT_TOOLTIPS) ||!m_wndStatusBar.SetIndicators(indicators,sizeof(indicators)/sizeof(UINT)))<br />
{<br />
TRACE0("Failed to create status bar\n");<br />
return -1;
}<br />
<br />
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
<br />
m_wndStatusBar.SetPaneText (0, _T("Ready"), 1);
m_wndStatusBar.GetStatusBarCtrl().SetTipText(0, _T("Application status"));
m_wndStatusBar.SetPaneInfo (0, 1, 1, 280);<br />
Your guidance on solving this problem is very much appreciated.
Thanks,
Goutam
|
|
|
|
|
Here is a snippet from the documentation of SB_SETTIPTEXT -
This ToolTip text is displayed in two situations:
When the corresponding pane in the status bar contains only an icon.
When the corresponding pane in the status bar contains text that is truncated due to the size of the pane.
|
|
|
|
|
Recently I used the TaskPanel functionin of BCGPro Control in my DLL. My calling sentences following below:
......
HINSTANCE m_hinstold = AfxGetResourceHandle();
AfxGetResourceHandle((HINSTANCE)AfxGetModuleInstance());
......
AddTask(_T("Task1",0,ID_TASK1));
......
AfxSetResourceHandle(m_hinstold);
......
and I added codes to deal with the event of the ID_TASK1 clicked. when I run it, I found no any effection. But I can create my Tree Contrl and respond my clicking. Why? How to resolve this quesion? Please give me a hand, thank you.
modified on Wednesday, October 20, 2010 7:19 PM
|
|
|
|
|
I've been trying to find of a working sample, but no luck!
I only managed to find MFC samples.
If someone knows how to get one in place by logic or a sample for it in Windows API code.
|
|
|
|
|
Depends what you mean by read-only. If you want the user to select from the drop-down list but not enter anything that is not on the list, then set the ComboBox style to CBS_DROPDOWNLIST (That's the name in winuser.h - your framework may have a different name).
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
What do you mean with "read only combobox"?
If you mean a combobox whose content cannot be changed by the user, simply disable it (it becames grayed, but there is not other way, however you can make it ownerdrawn and draw it with normal colors either if it is disabled).
If you mean a combobox where the user cannot type characters, but only select from a pre-defined list, use the CBS_DROPDOWNLIST style.
|
|
|
|
|
Hello . I have an MDI application with CView based on CScrollView and somewhere , in OnMouseMove handler I have :
if(pView->GetStyle() & WS_HSCROLL)TRACE("\n WS_HSCROLL \n");
if(pView->GetStyle() & WS_VSCROLL)TRACE("\n WS_VSCROLL \n");
without any effect ... either scrollbar appear or not , I haven't anything ... how can I know for sure of scrollbar appear or not ?
Thanks !
|
|
|
|
|
Have you called SetScrollSizes()[^] in your OnInitialUpdate() method?
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
|
|
|
|
|
Yes , everything it's allright there ... sometime scrollbar appear , sometime not ... I mean , if the window is reduced , scrollbar appear , if window is increased , scrollbar dissapear .
|
|
|
|
|
That sounds like correct behaviour. The scrollbar should only appear when the amount of data to display is larger than the client area of the window, either horizontally, vertically, or both. Are you sure that you are recalculating your scroll sizes correctly when the window size changes?
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Yes , I'm sure . Still , I can't solve the problem ... I see that VC2005 have CheckScrollBars(...) method , but I work in VC6 ...
|
|
|
|