|
Hiya,
I have a CSplitterWndEx class derived from CSplitterWnd. I have these two functions to only allow the user to move the bar so that the right pane is between 100 & 200 px wide. I have a variable called m_ULWidth in the CMainFrame class, which stores the width of the pane. It works fine, except for two things...
1) When I minimize and restore the app, the width of the pane reverts back to 150 px (what I initialized it to in the constructor)
2) If I keep clicking and dragging the splitter towards the right, it will still move a few pixels to the right each time even though the pane is at 100 pixels wide.
int CSplitterWndEx::GetSplitterWidth(void)<br />
{<br />
return m_cxSplitterGap + (m_cxBorder * 2);<br />
}
void CSplitterWndEx::OnMouseMove(UINT nFlags, CPoint point)<br />
{<br />
CRect rect;<br />
this->GetParentFrame()->GetWindowRect(rect);<br />
ScreenToClient(rect);<br />
<br />
if (point.x > (rect.right - 200) && point.x < (rect.right - 100)) <br />
CSplitterWnd::OnMouseMove(nFlags, point);<br />
}
void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect)<br />
{<br />
<br />
CFrameWnd::OnSizing(fwSide, pRect);<br />
CRect rect;<br />
int width, ideal;<br />
m_wndSplitterLR.GetColumnInfo(1,width, ideal);<br />
m_ULWidth = width;<br />
}
void CMainFrame::OnSize(UINT nType, int cx, int cy)<br />
{<br />
CFrameWnd::OnSize(nType, cx, cy);<br />
<br />
if(m_ULWidth < 100)<br />
m_ULWidth = 100;<br />
if(m_ULWidth > 200)<br />
m_ULWidth = 200;<br />
<br />
if ( m_bInitSplitter && nType != SIZE_MINIMIZED )<br />
{<br />
m_wndSplitterLR.SetColumnInfo( 0, cx - m_ULWidth - m_wndSplitterLR.GetSplitterWidth(), 100);<br />
m_wndSplitterLR.SetColumnInfo( 1, m_ULWidth, 75);<br />
m_wndSplitterLR.RecalcLayout();<br />
<br />
}
Any suggestions?
Shutter
|
|
|
|
|
Hi, everyone!
When using pointers, we often meet with such troubles,
one problem is the ownership - who (which function)
is responsible for deleting the pointer? Another problem is
there's no standard way that you can tell if a pointer points
to the heap or to the stack. If it's to the heap, then
you can delete it; if it points to the stack, then you'd better
not use delete on the pointer.
I have searched some materials on the problem. One solution others
suggested is using const pointer (for example, int * const). But I do
not understand why it can resolve the trouble. (Other solutions include
smart pointers and reference.)
Can anyone show me an example?
Thanks in advance,
George
|
|
|
|
|
I think this is more of an academic discussion than something you will do in your profession. In the last 6 years I have written 300 thousand lines of code and I have never for a minute thought about any of this discussion. If a function is passed a pointer 99.99% of the time the function should not delete it. If a function returns a pointer the documentation should describe how to delete it. There is more than just on the stack or heap. You can allocate memory with new, malloc, through COM or one of the VirtualAlloc functions. Deleting it with the wrong one will lead to problems.
John
|
|
|
|
|
Thanks, John buddy!
George
|
|
|
|
|
I remember reading in Scott Meyers' book More Effective C++ that it's basically impossible to tell from just a pointer whether it points into the heap or elsewhere. And on deciding who deletes the pointer, this can probably best be achieved with comments. I do not see how const pointer would help.
|
|
|
|
|
Thanks, Philnessosity buddy!
George
|
|
|
|
|
I open a Modeless dialog. But this dialog is always on top over my Main App. I want to be able to go back to my main app with the dialog in the back. How can I do that?
I also want the dialog to get its own button on the taskbar. I have done that before but can’t figure out how I did that.
I do get both of these behaviors if I show the dialog from it’s own gui thread. But I was hopping to avoid that
/Mathias
|
|
|
|
|
|
Create the dialog with a parent of NULL to let it go under your app, and add the WS_EX_APPWINDOW extended style to give it a taskbar button.
--Mike--
Yeah, payin' the bills with my mad programming skillz.
Defraggin' my hard drive for thrills.
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
Hi:
I have recently created a "Win32 Application" project or, more accurately "A Simple Win32 Application".
but i need to use a Worker-Thread in this app so i useed
AfxBeginThread()function,but when i want to compile project,i receive the following error:
error C2065: 'AfxBeginThread' : undeclared identifier
Is it possible to use this function in Win32 Application ?
Please Help me.
Best Regards.
|
|
|
|
|
Nope. AfxBeginThread is declared in afxwin.h , which is a part of MFC framework.
In Win32 apps, use _beginthread instead.
Regards,
BB
|
|
|
|
|
Win32 apps should use _beginthreadex , not _beginthread.
|
|
|
|
|
Both may be used, however _beginthreadex is better (security information, initial state, autoclosing handle, etc.). Thanks for your comment.
Regards,
BB
|
|
|
|
|
Hey Friends I Have Created an MDI Application in which I Want that on Click of a Button All Windows Should Close.
I Have Used CFrameWnd as the FrameWindow.
I Know of CWinApp::CloseAllDocuments(BOOL) but it do not Closes these Windows ?
PL Help.
|
|
|
|
|
Check out the CDocTemplate::CloseAllDocuments function.
Regards,
BB
|
|
|
|
|
Hi ppl
well my problem is with explicit linking here.Actually there is this function called
"SetLayeredWindowAttributes" that i want to link explicitly following is the code:
typedef BOOL (CALLBACK*LPFNSETLAYEREDWINDOWATTRIBUTES)(COLORREF,BYTE,DWORD);
...
BOOL CMainFrame ::TranparentWindow()
{
HINSTANCE hDLL; // Handle to DLL
LPFNSETLAYEREDWINDOWATTRIBUTES lpfnSetLayeredWindowAttributes; // Function
pointer
COLORREF color = RGB(100,100,100);
BYTE alpha;
DWORD what;
hDLL = LoadLibrary(_T("USER32.DLL"));
if (hDLL != NULL)
{
lpfnSetLayeredWindowAttributes =
(LPFNSETLAYEREDWINDOWATTRIBUTES)GetProcAddress(hDLL,"SetLayeredWindowAttributes");
if (!lpfnSetLayeredWindowAttributes)
{
// handle the error
FreeLibrary(hDLL);
return FALSE;
}
else
{
// call the function
BOOL status;
status = lpfnSetLayeredWindowAttributes(color,alpha,what);
}
}
}
I am calling this function on the OnCreate message handler there are no linker
problems as well when the program is executed it gives me an error regarding ESP
tellimg me something about conflicting calling conventions anyone having any idea wats
the problem here please do tell me
Thanks in advance
Ahmed ajmal
|
|
|
|
|
You're missing an argument from the prototype for SetLayeredWindowAttributes :
BOOL SetLayeredWindowAttributes(
HWND hwnd,
COLORREF crKey,
BYTE bAlpha,
DWORD dwFlags
);
Software Zen: delete this;
|
|
|
|
|
Hi !!
What is the meaning of following statements:
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000
generated by visual studio in header files.
|
|
|
|
|
It tells the compiler to only process the header file once.
Software is everything. It also sucks. Charles Fishman [^]
Awasu 1.0.3 (beta)[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
As Taka said, it tells the compiler to process the header file only once
(unlike the usual #ifndef _HEADERNAME #define _HEADERNAME ..., it doesn't need to open the file again, start parsing etc.)
It's implemented only in certain compiler versions, for which is the additional #ifdef _MSC_VER check
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
I want to use my own dialog as a base for another one. Don't want to copy anything from the base dialog, just construct it and ready.
Someone confuses me by advising I have to add/change a constructor. I tried his way (adding UINT nId) as good as I've understood him. But seems to be not good enough. I think I'm making mistakes with the dialog id. I was told to remove the "enum {IDD...}" line. I don't understand.
What do I have to do in my base dialog and what in the derivated dialog (.h + .cpp)?
This is my code which does NOT construct the derivated dialog:
***MyBaseDlg.h***
// Two constructors
CMyBaseDlg (CWnd* pParent = NULL); // Not used by the derivated Dialog
CMyBaseDlg (UINT nIDTemplate, CWnd* pParent = NULL); // Use this one
*** MyBaseDlg.cpp***
CMyBaseDlg:: CMyBaseDlg (CWnd* pParent /*=NULL*/)
: CDialog(CMyBaseDlg::IDD, pParent)
{
}
CMyBaseDlg:: CMyBaseDlg (UINT nIDTemplate, CWnd* pParent /*=NULL*/)
: CDialog(nIDTemplate, pParent)
{
}
Derivated Dialog: class CSecondDlg : public CMyBaseDlg
***SecondDlg.h***
CSecondDlg(UINT nID, CWnd* pParent = NULL);
***SecondDlg.cpp***
CSecondDlg:: CSecondDlg (UINT nIDD, CWnd* pParent /*=NULL*/)
: CMyBaseDlg (nIDD, pParent)
{
}
Call the derivated dialog somewhere in my code:
CSecondDlg dlg(CMyBaseDlg::IDD); // How to call correctly?
Thanks,
Oli
|
|
|
|
|
Here it goes:
CMyBaseDialog::CMyBaseDialog(UINT IDD, CWnd* pParent )<br />
: CDialog(IDD, pParent)<br />
{<br />
}<br />
<br />
CSecondDlg::CSecondDlg(CWnd* pParent )<br />
: CMyBaseDialog(CSecondDlg::IDD, pParent)<br />
{<br />
}<br />
<br />
CSecondDlg dlg;
Naturally, the "embedded" IDD should only be contained in CSecondDlg (it is not absolutely required, but helpful for ClassWizardry and such stuff).
Regards,
BB
|
|
|
|
|
Hi,
How can I use the GetDecryptionExponent function with RSAES_OAEP_SHA_Decryptor ?
This is really important for me, thank you
|
|
|
|
|
You are more likely to get help on Crypto++ by posting to their mailing list.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
the qusetion is at:
http://www.codeproject.com/listctrl/xlistctrl.asp?forumid=3227&fr=101&select=478331&df=100#xx478331xx
|
|
|
|