|
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
|
is it possible to put a checkbox in CListCtrl header ? if so how can i do that?
Thanks in advance.
|
|
|
|
|
Subclass it and you can do almost whaterver you want with the control
For instance, make it custom draw, and draw a checkbox along with the header text. Or just set image list that has a checkbox images (checked/unchecked) and change header item image when necessary (check/uncheck). Then you'd have to process WM_LBUTTODNDOWN to detect if user clicked the check box and change the checkbox state. Handling keyboard messages might be good idea (WM_SETFOCUS/WM_KILLFOCUS/WM_KEYDOWN), to allow user navigate the control via keyboard
Edward
|
|
|
|
|
I recently wrote an application with multiple custom controls all of which are derived from CWnd. My problem is that when I resize one of the controls the internal controls overlap which is ok. My problem is that I want to set the order in which they are drawn(z-order) but can't seem to get it. Anyone?
|
|
|
|
|
Try to set WS_CLIPSIBLINGS style for the child windows
Edward
|
|
|
|
|
I understand the concept of clipping children when repainting child components. The problem in more detail is as follows. I have two child custom controls inside a parent custom control(all derived from CWnd). When I move or resize the parent window I also move the inner controls.
When they overlap I want to be able to set one of the components to be always on top, even when another control gets focus. The code is roughly as follows, when I move the parent window..
void CParentCrl::OnSize(UINT nType, int cx, int cy)
{
CRect aRect,bRect;
// Calculate new child rects(not shown)
.
.
.
child1.MoveWindow(aRect);
child2.MoveWindow(bRect);
}
now from here how do I endure that child1(or two) will always be drawn on top of the other control?
|
|
|
|
|
The CWnd::SetWindowPos() function allows you to specify z-order of windows.
Robert-Antonio
"Love without sex is like a fish without antlers"
|
|
|
|
|
Hi altogether!
I'm trying to check whether a given path of a folder (also on the network or just a drive) really exists. I'd like to do this without using the Shlwapi.dll, but I have no idea how to do this. Any ideas?
Thank you very much,
Marcus.
|
|
|
|
|
_access()
_stat()
CFile::GetStatus()
GetFileAttributes()
can all be used.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
I just tried CFile::GetStatus(), but this doesn't work for network locations. But I think one of the other functions will do the job. Thank you very much!
|
|
|
|
|
khb wrote:
I just tried CFile::GetStatus(), but this doesn't work for network locations.
Correct. I did not bother to read the docs (fine print) for each function I mentioned. I just wanted to throw a bunch of them out on the table so you would have plenty to choose from.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
No problem. My intention was not to bother you. I just wanted to share what I found out for the case that anybody else reads this thread (maybe because he has the same problem to solve). Thanks again for your help!
|
|
|
|
|
I'm currently using OutputDebugString in my code but would like to use a cout type operation to output new debug messages.
How do you get something like
dout << "hello world"
where the output ends up wherever outputDebugString normally puts its stuff.
Ok maybe it should be called
doh << "hello world"
since most debug messsages are error messages of the homer Simpson type.
|
|
|
|
|
don wade wrote:
I'm currently using OutputDebugString in my code but would like to use a cout type operation to output new debug messages.
How do you get something like
dout << "hello world"
where the output ends up wherever outputDebugString normally puts its stuff.
Ok maybe it should be called
doh << "hello world"
since most debug messsages are error messages of the homer Simpson type.
There may be some way of redirecting output to the debugger window, but I don't know how to do it. At a more basic level, the following works:
class OutputDebug
{
public:
void operator<<(TCHAR *str)
{
OutputDebugString(str);
}
};
OutputDebug doh;
Thereafter, you can use
doh << _T("Hullo world.")
If you want something more "cout-like" in that it can handle ints etc., then the following seems to work:
<Edit> The template parameter was originally omitted from the std::basic_ostringstream declaration in the code below because the angle brackets were HTML-ised. This has now been corrected.
</Edit>
#include <iostream>
#include <sstream>
class OutputDebug
{
std::basic_ostringstream<TCHAR> oss;
public:
OutputDebug & operator<<(TCHAR *str)
{
OutputDebugString(str);
return *this;
}
OutputDebug & operator<<(int x)
{
oss << x;
OutputDebugString(oss.str().c_str());
oss.str(_T(""));
return *this;
}
OutputDebug & operator<<(float f)
{
oss << f;
OutputDebugString(oss.str().c_str());
oss.str(_T(""));
return *this;
}
OutputDebug & operator<<(double d)
{
oss << d;
OutputDebugString(oss.str().c_str());
oss.str(_T(""));
return *this;
}
};
OutputDebug doh;
With this, you can do things like:
doh << _T("This is error number ") << 155 << _T(". The value of x is ") << 3.445 << _T(".\n");
John Carson
"I wish to propose for the reader's favourable consideration a doctrine which may, I fear, appear wildly paradoxical and subversive. The doctrine in question is this: that it is undesirable to believe a proposition when there is no ground whatever for supposing it true."
- Bertrand Russell
|
|
|
|
|
I´ve created an edit box Member Variable and I have to use it from another file but I don't know how could I do it.
In my tree view I have both files but, how could I use my m_strVar from the main file in the other one, so that I could update the edit box from this last file.cpp?
Thank you in advance
I have no idea
|
|
|
|
|
How about extern ?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
How could I use this?
If I write
extern m_strVal;
in my main file .cpp I'd get a redefinition, wouldn't I?
Thank you!
I have no idea
|
|
|
|
|
satcat wrote:
If I write
extern m_strVal;
in my main file .cpp I'd get a redefinition, wouldn't I?
Per the documentation:
The extern keyword declares a variable or function and specifies that it has external linkage (its name is visible from files other than the one in which it's defined). When modifying a variable, extern specifies that the variable has static duration (it is allocated when the program begins and deallocated when the program ends). The variable or function may be defined in another source file, or later in the same file. In C++, when used with a string, extern specifies that the linkage conventions of another language are being used for the declarator(s).
In other words, no, you would not get a redefinition error.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Thank you, I'll try on this way
|
|
|
|
|
If it is a member variable of a class the extern keyword does not apply, extern applies to globaly declared (non-static) variables.
If the class variable is declared grobaly, then the extern keyword may be applied to the class variable (giving you access to all public members of that class).
If the member variable contains the same information no matter how many instances of the class are created, then you might as well make it a static member. In which case you can modify it even if no intances of the class exist yet. (Example: CMyClass::m_strVar = _T("new data");)
If you do not want to make it a public member but still want to access the member directly (without use member functions), then make the class that needs direct access a friend of the class containing them member variable.
INTP
|
|
|
|
|
I have no idea about this... Perhaps if I try to explain you with some code cuts you could help me:
In my main code1.cpp I have defined a edit box with a member variable. In my code it appears on this way:
<br />
CIVOCOMDlg::CIVOCOMDlg(CWnd* pParent )<br />
: CDialog(CIVOCOMDlg::IDD, pParent)<br />
{<br />
m_strHeard = _T("");<br />
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);<br />
}<br />
<br />
void CIVOCOMDlg::DoDataExchange(CDataExchange* pDX)<br />
{<br />
CDialog::DoDataExchange(pDX);<br />
DDX_Text(pDX, IDC_GOT, m_strHeard);<br />
}<br />
Then in this code1.cpp I create a Grammar object:
<br />
BOOL loadGrammar( TCHAR *pszFile, BOOL bDictGram,<br />
ISRGramCommon **ppISRGramCommon )<br />
{<br />
...<br />
IUnknown * pIUnkGram;<br />
CGramDictSink *pGramDictSink = new CGramDictSink(NULL);<br />
pGramDictSink->AddRef();<br />
<br />
hRes = g_pISRCentral->GrammarLoad( SRGRMFMT_DICTATION, sData,<br />
pGramDictSink, IID_ISRGramNotifySink,<br />
&pIUnkGram );<br />
<br />
pGramDictSink->Release();<br />
...<br />
hRes = pIUnkGram->QueryInterface( IID_ISRGramCommon,(void **)ppISRGramCommon );<br />
pIUnkGram->Release();<br />
<br />
hRes = (*ppISRGramCommon)->Activate( NULL, FALSE, NULL );<br />
<br />
return SUCCEEDED( hRes );<br />
}<br />
In the code2.cpp file I have:
<br />
STDMETHODIMP CGramCFGSink::PhraseFinish( DWORD dwFlags,<br />
QWORD ,<br />
QWORD ,<br />
PSRPHRASE pSRPhrase,<br />
LPUNKNOWN )<br />
{<br />
if( !( dwFlags & ISRNOTEFIN_RECOGNIZED ) ||<br />
!( dwFlags & ISRNOTEFIN_THISGRAMMAR ) )<br />
{<br />
return S_OK;<br />
}<br />
<br />
PSRWORD pSRMax = (PSRWORD)( (BYTE*)pSRPhrase + pSRPhrase->dwSize );<br />
PSRWORD pSRWord = (PSRWORD)( pSRPhrase->abWords );<br />
TCHAR szText[256] = { _T('\0') };<br />
int nWords = 0;<br />
while( pSRWord < pSRMax )<br />
{<br />
if( nWords++ != 0 )<br />
_tcscat( szText, _T(" ") );<br />
<br />
_tcscat( szText, pSRWord->szWord );<br />
pSRWord = (PSRWORD)( (BYTE *)pSRWord + pSRWord->dwSize );<br />
}<br />
<br />
SetDlgItemText(m_hDlg, IDC_GOT, "Unrecognized\0");<br />
return S_OK;<br />
}<br />
This "SetDlgItemText(m_hDlg, IDC_GOT, "Unrecognized\0");" doesn't work... It should write in the edit box the text "Unrecognized" whichever I say. I don't know what could I do so it works. Please, help me!
Thank you!
|
|
|
|
|
First:
CGramDictSink *pGramDictSink = new CGramDictSink(NULL);
// Make sure pGramDictSink is not NULL
// If it is clean up and exit with failure.
Secound:
m_strHeard does not seem to be needed, unless the string contained in it needs
to be accessed after the dialog is closed or by some other class if the dialog
is not modal.
Third:
"Unrecognized\0" is equivalent to the folowing:
char str[14] { 'U','n','r','e','c','o','g','n','i','z','e','d','\0','\0' };
You sould use "Unrecognized".
Forth:
Just incase you ever want to compile your code as UNICODE you should declare
your strings as follows:
_T("Unrecognized")
Otherwise: Using function macros like _tcscat() does not make since.
Fith:
The line "TCHAR szText[256] = { _T('\0') }" looks dangerious.
How can you be absolutly sure that the final string will not exceed the size
of the buffer. Use CString instead (if using MFC), it will dinamicaly icrease
the size of the buffer as needed.
Sixth:
As for why SetDlgItemText(m_hDlg, IDC_GOT, "Unrecognized\0") does not work.
I do not know, if the dialog handle and control ID are valid it should work.
Of cource you could be overrunning the buffer mentioned above, which may
resault in your problem (I dought it). Or if the code presented here is not part of the dialog derived class and the dialog is modal, then the function call will only occur when the dialog is closed, in which case the dialog handle will be invalid.
Seventh:
It looks like you need to add more error checking to your code.
Eighth:
In the future when you post code, use <pre> before the code and </pre> after
the code. That way the we will not have to reformat it, to see what is happening.
Finaly:
I appoligise, if I sound abrubt, but this does not seem to apply to the
originaly question at all.
INTP
|
|
|
|
|
Thank you for your help...
I'm a newbie and I have a very little bit idea about programming in Visual C++, and so I got lots of mistakes in my message. My problem is that I can't write in the main window edit box from the gramsink.cpp code. That's the reason why I wrote both codes because it's the only thing doens't work in the application.
If I write a MessageBox I get in a new window what I want to be written in the main window so the code works. If i use m_strHeard in gramsink.cpp I get theerror message "Undeclared identifier". This is what I meant with my prior question. I only wanted a method so I could write in the existing window Edit Box and not in a new window. Using extern or other way (I don't know).
Sorry if you've got disturbed with my greenness.
Regards.
|
|
|
|
|
Can anyone tell me how i can find the Hard Disk Manufacturer Serial Number (Not Volume Serial Number) ?
Any help would be greatly appreciated.
Thanks.
|
|
|
|