|
in OnCreate(LPCREATESTRUCT lpCreateStruct) of the CView.. Basically I have an old app (IRC) type app where I created a SDI of CView type and I create 2 edit windows one on the top 90% of the screen and one on the bottom 10%.. I create the windows and set the styles in OnCreate() of the CView.. Then in the OnSize I resize both windows. The top 90% window has the style of WS_EX_CLIENTEDGE and the bottom 10% has the style of WS_EX_STATICEDGE.. it looks just like MIRC..
I could email you a sample.. maybe your doing something a little different than I am.
Rob
|
|
|
|
|
Here is what I am doing...
// In the header...
CEdit m_wndTop;
CEdit m_wndBottom;
// In the source....
int CIRCViewView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
if( !m_wndTop.Create(WS_CHILD|WS_VISIBLE|WS_VSCROLL|ES_MULTILINE, CRect(), this, 100) )
return -1;
if(!m_wndBottom.Create(WS_CHILD|WS_VISIBLE|ES_AUTOVSCROLL|ES_MULTILINE, CRect(), this, 101))
return -1;
m_wndTop.ModifyStyleEx(WS_EX_CLIENTEDGE, 0);
m_wndTop.SendMessage(WM_SETFONT, (WPARAM)GetStockObject(SYSTEM_FIXED_FONT));
m_wndBottom.ModifyStyleEx(0, WS_EX_STATICEDGE);
m_wndBottom.SendMessage(WM_SETFONT, (WPARAM)GetStockObject(SYSTEM_FIXED_FONT));
return 0;
}
void CIRCViewView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
if( nType != SIZE_MINIMIZED )
{
static const int iHeight = 20;
m_wndTop.MoveWindow(0, 0, cx, cy - iHeight);
m_wndBottom.MoveWindow(0, cy - iHeight, cx , iHeight);
}
}
|
|
|
|
|
Thanks a lot.
Finally by testing this code I got it working, which is all I wanted.
I just got confused. My code changes from "works just fine" to "no clientedge at all" when I add/remove the line:
m_wndBottom.MoveWindow(0, cy - iHeight, cx , iHeight);
I have absolutely no idea what MoveWindow has to do with painting the ClientEdge or not.
But I had to catch WM_SIZE anyway, so I'm happy.
|
|
|
|
|
This maybe the style your looking for too... instead of the ones I suggested..
m_wndTop.ModifyStyleEx(0,WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE);
for a border or
m_wndTop.ModifyStyleEx(0,WS_EX_CLIENTEDGE|WS_EX_STATICEDGE);
for a standard edit box..
|
|
|
|
|
I'm working on a MDI application with different menus for the CMDIFrameWnd main frame and the CView child frames. Based on data in each document, I want to dynamically add new menu choices to the menu shown for that child frame. GetMenu() only gives me access to the CMDIFrameWnd main frame menu. How do I get access to the menu for the CView child frame?
|
|
|
|
|
Im not sure if I understand your question 100% but here is how I load a menu for my view... maybe it will help you out.. You could create different menus for each doc or view you have and load them like this..
void CMyView::OnRButtonUp(UINT nFlags, CPoint point)
{
ClientToScreen(&point);
CMenu menu;
menu.LoadMenu(IDR_POP_UP_VIEW);
CMenu* pPopup = menu.GetSubMenu(0);
CWnd* pWndPopupOwner = this;
while(pWndPopupOwner->GetStyle() & WS_CHILD)
pWndPopupOwner = pWndPopupOwner->GetParent();
pPopup->TrackPopupMenu(TPM_LEFTALIGN,
point.x, point.y, pWndPopupOwner);
CRichEditView::OnRButtonUp(nFlags, point);
}
|
|
|
|
|
Thank you but I was trying to make changes to the main menu at the top of the application, not a pop-up menu. As it turns out, the solution was simple but a little obfuscated. I had to delete and reload the menu data each time the child frame activated by using GetMenu() called from the main window, not the child frame, and it had to be done when the child frame was activated, not when the child frame's view class was activated, using the ON_WM_MDIACTIVATE event or else I'd wind up getting the menu used when there are no documents instead of the menu for documents. So I had been using the right functions just not in the right places or at the right moment.
|
|
|
|
|
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_TYCATTTYPE,
RUNTIME_CLASS(CTycattDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CTycattView));
AddDocTemplate(pDocTemplate);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
::DestroyMenu(pDocTemplate->m_hMenuShared);//=pMainFrame->NewMenu();
// pDocTemplate->m_hMenuShared = NULL;
pDocTemplate->m_hMenuShared = pMainFrame->GetMyMenu();
GetMyMenu() prepare your new menu handle
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
Hi, apparently, no-one seems to be able to answer my question on newsgroups because I guess it's more complicated than rocket science.
I'll make this real simple. Suppose I have one modeless dialog called, CFirstDialog that gets displayed from the document class upon a menu selection. In the CFirstDialog class, I have an on OnOK handler:
void CFirstDialog::OnOk()
{
// I simply wish to open up another modeless dialog box upon closing this one
m_mySecondDialog = new CSecondDialog(this);
m_mySecondDialog->Create(CSecondDialog::IDD, this);
m_mySecondDialog->ShowWindow(SW_SHOW);
// Calling DestroyWindow destroys this dialog, so the second dialog
// will show, but it will show only for an instant obviouly because
// it's a member variable that gets destroyed when this object is destroyed.
DestroyWindow();
}
How do I make CSecondDialog show up while at the same time closing CFirstDialog? If I don't call DestroyWindow, but say, call EndDialog, then there's a memory leak since it's modeless, but calling DestroyWindow will not enable the second modless dialog to stay created. I know that I could just merely have the document class (the one that opened up CFirstDialog to begin with) open up CSecondDialog, but this would require a bit of strange logic, like setting variables in CFirstDialog to signal that it's closing so that the document class can therefore open up CSecondDialog, but this would require goofy logic, but is this basically the only way? Can anyone please tell me how to solve this tougher than rocket science problem?
|
|
|
|
|
One solution is to show the modeless dialog box after the modal dialog box returns from DoModal().
Kuphryn
|
|
|
|
|
The problem is that both dialogs are modeless.
|
|
|
|
|
You could create a function in your main application to create the second dialog box.. Then in your first dialog OnOK() PostMessage or SendMessage to the main application telling it to launch the second dialog..
Rob
|
|
|
|
|
Heres another option.. Its not as good as the first one but its much easier...
In your OnOK dont close the dialog just HIDE it and show the second dialog box..
In your Second Dialogs INIT() do a..
// Kill the 1st dialog..
CWnd *pOtherWnd = CWnd::FindWindow(NULL, _T("Dialog 1 Title.."));
if (pOtherWnd)
pOtherWnd->PostMessage(WM_CLOSE);
|
|
|
|
|
Hi Rob Jones! THANK YOU VERY, VERY, VERY MUCH MAN!!!!!!!!!!!!!!
Joey
|
|
|
|
|
Hi all,
Has anyone ever experienced or read of a problem where ::HttpSendRequest hangs on the INTERNET_STATUS_RECEIVING_RESPONSE status event?
I am experiencing this problem intermitently in an application that I have written. I am using WININET syncrhonously an I have enabled the status callback, that is how I know the function is hanging at the INTERNET_STATUS_RECEIVING_RESPONSE event.
My app will appear to work fine for quite a while, but then the thread that calls ::HttpSendRequest will hang. I detect this with a second thread to implement the timeout test as MSDN reports that this is the only reliable way to handle timeouts for versions of IE older than 5.5. After I detect the timeout, no requests work properly after that point until I restart my app.
If anyone has insight to this I would really appreciate it.
Thank you.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
That's why I use Winsock.
Todd Smith
|
|
|
|
|
What about HTTPS support?
Do you have any experience with that? Is it as simple as using the SSL functions instead of the regular socket functions?
Thanks
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
yep. But this depends on what are you doing - e.g. for client side apps the wininet is quite OK, but when talking about 24/7 apps it is better to use the pure winsock stuff + say few hundred lines for SSPI usage.
And once you have some other SSL support(I think there are some on codeproject or look for OpenSSL or others) I will stick to it and don't want to see wininet any more in my life
linx:
SSL/TLS client/server for .NET[^]
CSSLSocket[^]
|
|
|
|
|
I've often wondered what is the reasoning behind passing structs by pointers rather than by reference. Can anyone give me a good motivation for choosing one over the other? I see it all the time in MFC -- is it just MS standard?
For instance, if I have the following:
typedef struct POINT
{
double x;
double y;
} tagPOINT, *LPPOINT;
void GetCurrLoc(LPPOINT pt)
{
pt->x = 3.2;
pt->y = 2.4;
}
void GetCurrLoc(POINT& pt)
{
pt.x = 3.2;
pt.y = 2.4;
}
Is one any better than the other, besides the fact that passing by pointer is (slightly) easier when using dynamically allocated structs.
Thanks,
Dean
|
|
|
|
|
when passing objects ( struct ) by pointer, you always need to check the incoming pointer for NULL.
if you pass by reference, you are sure that the class/struct is valid.
Max.
|
|
|
|
|
I'm sorry, but that is a false statement. Look at this code:
struct SomeStruct { ... };
SomeStruct& func() {
SomeStruct s;
return s;
}
void func2(SomeStruct& s) {
s.DoTheFunkyStuff();
}
func2(func());
So, just because it's a reference doesn't guarantee its validity.
I feel that references are in the C++ language because it's syntactic sugar. I have no proof of this being the case, but I just can't find any other reasonable explanation for it.
--
Only in a world this sh*tty could you even try to say these were innocent people and keep a straight face.
|
|
|
|
|
Returning a reference to a object declared on the stack in a function is wrong and bad coding! and will generate a very basic compiler warning ( level 1 ):
It's only a warning because ( I think ) references are implemented as pointers.
from MSDN :
Compiler Warning (level 1) C4172
returning address of local variable or temporary
A function returns the address of a local variable or temporary object. Local variables and temporary objects are destroyed when a function returns, so the address returned is not valid.
Redesign the function so that it does not return the address of a local object.
Max.
|
|
|
|
|
Yes, and so is using a pointer to a previously deleted object.
It is bad yes, but it is still possible. Thus you can't rely on references being always correct.
I know my example was trivial and is obviously erroneous, but I'm still right
--
There's a new game we like to play you see. A game with added reality. You treat me like a dog, get me down on my knees.
We call it master and servant.
|
|
|
|
|
Or what about this one?
class SomeClass {
RefClass& ref;
public:
SomeClass(RefClass& ref_) : ref(ref_) { ... }
};
.... somewhere in 10<sup>6</sup> lines of code ....
RefClass* pRef = new RefClass();
SomeClass* pObj = new SomeClass(*pRef);
.... somewhere else among those 10<sup>6</sup> lines of code ....
delete pRef;
See what I mean? SomeClass::ref isn't valid. Yes it's a bug, but you can't say that ref is valid after the delete pRef. Same thing goes for pointers to object. Just because a pointer is not NULL doesn't make it valid. That's a dangling pointer, and as you can see, there are also dangling references. In both cases you have a bug on your hands, but it still doesn't make your previous statement true, which was my main argument all along.
BTW, you can do this in VS.NET and most likely VC6:
struct Test { int x; };
int _tmain(int argc, _TCHAR* argv[])
{
Test& ref = *((Test*)NULL);
return 0;
}
No crash, no nothing. Yet, ref will reference "an object" at NULL. Put a breakpoint on return 0 and you'll see.
I still believe that the only advantage of references over pointers are purely syntactical.
--
There's a new game we like to play you see. A game with added reality. You treat me like a dog, get me down on my knees.
We call it master and servant.
|
|
|
|
|
That is a bug in the program which is a different beast. As the standard states, a well defined program can't have a NULL reference where a pointer can have a NULL pointer.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|