Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PreCreateWindow in CDialog

Posted on 2002-07-21
9
Medium Priority
?
1,425 Views
Last Modified: 2013-11-20
Hi,
I created a class which derive from CDialog, in which I want to remove some styles before the dialog creation. I tried to catch PreCreateWindow, but I dont stop there.
1. Why ???
2. how can I remove/add styles On dialog creation (without changing it in the resources !)

igal.
0
Comment
Question by:igalb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 1

Expert Comment

by:prakashsl
ID: 7168881
Hi,

Why not change in the rc file itself, open ur rc file in text mode and keep whatever styles you want and then run it, thatz it,


or else u can tackle it in initdialog also.

prakash


0
 

Author Comment

by:igalb
ID: 7169113
my question was why dont I stop in PreCreateWindow.
0
 
LVL 1

Expert Comment

by:prakashsl
ID: 7169177
Hi,

Sometimes the code just doesn't go to the precreatwindow  function, if you are using create functions like
Create(IDD_DIALOG_GTK);

It sometimes skips of this function or is overridden by initdialog.

prakash
0
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
LVL 1

Expert Comment

by:prakashsl
ID: 7169189
Hi,

PreCreateWindow function is actually called by the framework, which usally exits in MDI and SDI, but this will not be present in dialog based application, May be u can create a dialog inside another dialog and then use it.

Just check this msdn help... This is a snippet of help found in msdn...

To change the default window attributes used by a framework application created with AppWizard, override the window’sPreCreateWindow virtual member function. PreCreateWindow allows an application to access the creation process normally managed internally by theCDocTemplate class. The framework calls PreCreateWindow just prior to creating the window. By modifying theCREATESTRUCT parameter to PreCreateWindow, your application can change the attributes used to create the window.


regards
prakash
0
 
LVL 8

Expert Comment

by:fl0yd
ID: 7170051
You can do it in OnInitDialog:

LONG lStyle = ::GetWindowLong( m_hWnd, GWL_STYLE );
lStyle |= ( STYLES | TO | BE | ADDED );
lStyle &= ~( STYLES | TO | BE | REMOVED );
::SetWindowLong( m_hWnd, GWL_STYLE, lStyle );

To change extended style use GWL_EXSTYLE in place of GWL_STYLE.
0
 
LVL 1

Accepted Solution

by:
prakashsl earned 90 total points
ID: 7170936
Hi floyd,
But this call is in initdialog. offcourse you can add and delete styles in the way you have said, but his question was why not in precreatewindow() function in a dialog based application.
The problem is precreatewindow function is called from the framework which exits with mdi and sdi application and not with dialog based.
So he has got to pull his code out of precreatewindow and put in in initdialog() function, and then do the way you have said or may be by directly setting the new styles, or may be even by editing the rc file if it is having fixed styles which is predetermined.

regards
prakash


0
 
LVL 8

Expert Comment

by:fl0yd
ID: 7171299
Yes?? This is in OnInitDialog since PreCreateWindow isn't called for dialogs/dialog-based applications. I don't really see why you think there is that much trouble with taking code from one function and placing it in another one. I'm sure you have heard of copy-paste, haven't you?

p.s.: the question also included "(without changing it in the resources !)"
0
 
LVL 1

Expert Comment

by:prakashsl
ID: 7171419
Hi floyd,

Sorry,
i didn't see this line "(without changing it in the resources !)" in the question

::)

prakash
0
 
LVL 8

Expert Comment

by:fl0yd
ID: 7171515
igal, still listening? I found an easier way since you are using MFC. Just use

ModifyStyle( dwRemove, dwAdd ); // or
ModifyStyleEx( dwRemove, dwAdd );

in OnInitDialog or better yet in OnCreate. Don't worry about the nFlags-argument in both of those function calls -- if you don't specify a value they will only change the window style without calling ::SetWindowPos.

int CMyDialog::OnCreate( LPCREATESTRUCT lpCreateStruct ) {

    if( -1 == CDialog::OnCreate( lpCreateStruct ) )
        return -1;

    DWORD dwRemove = styles_to_be_removed;
    DWORD dwAdd = styles_to_be_set;
    ModifyStyle( dwRemove, dwAdd );

    return 0;
}
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question