Cdaoexception error code = 340

cdaoexception error code = 340

q Day 5 You write SQL and C++ code to add, modify, and delete data in relational values for errors to ensure code clarity and brevity. I'm trying to import data from a text file in BO XIR2 and get the following error: CDaoException SCODE_CODE = SCODE_FACILITY = 4 SCODE_SEVERITY = 1. MFC ActiveX Controls: Returning Error Codes From a Method. MFC ActiveX Controls: Properties. MFC ActiveX Controls: Adding Stock Properties.

Consider, that: Cdaoexception error code = 340

EYBOARD ERROR OR NO KEYBOARD PRESENT
Cdaoexception error code = 340
Error no 1064 sql
Cdaoexception error code = 340

Cdaoexception error code = 340 - something

MFC Programming With Visual C++ 6 Unleashed

Citation preview

Table of Contents Introduction

1 Foreword 4 About the Author 6 Core MFC 10 The MFC Architecture 10 A Brief History of MFC 10 The MFC Class Hierarchy 10 CObject 10 CCmdTarget 10 CWinThread 10 CWinApp 10 CWnd 10 CFrameWnd 10 CView 10 CDocument 10 Summary 10 MFC Dialogs, Controls, and Data Interaction 36 Creating an Application 36 Starting and Using MFC AppWizard 36 The AppWizard-Generated Code 36 Modifying the Application 36 Adding Dialog Controls 36 Adding Initialization 36 Using Dialog Controls 36 ToolTips 36 Enabling ToolTips 36 Displaying Text 36 Dialog Data Exchange 36 Standard DDX 36 UpdateData 36 Using Standard Dialog Boxes 36 File Open/Save 36 Color Selector 36 Font Selector 36 Print Dialog 36 Summary 36 The Windows Common Controls 60 Initializing and Using the Common Controls 60 Notifications for Windows Common Controls 60 The Notification Message Structure 60 Overview of the Notification Process 60 A Better Notification Handling Scheme 60 Specifying Notification Ranges with ON_NOTIFY_RANGE 60 Hot Key Controls: Class CHotKeyCtrl 60 CHotKeyCtrl Class Methods 60 Creating and Initializing a CHotKeyCtrl Object 60 Using a Hot Key Control 60 Spin Controls: Class CSpinButtonCtrl 60 Spin Control Styles 60 CSpinButtonCtrl Messages 60

CSpinButtonCtrl Class Methods 60 Creating and Initializing a Spin Control 60 Sample Program: SPIN1 60 Slider Controls: Class CSliderCtrl 60 Slider Control Styles 60 CSliderCtrl Messages 60 CSliderCtrl Class Methods 60 Creating and Initializing a Slider Control 60 Sample Program: Slider Controls (SLIDER1) 60 Sample Program: SLIDER1 60 Progress Bar Controls: Class CProgressCtrl 60 CProgressCtrl Class Methods 60 Creating and Initializing a CProgressCtrl Object 60 Using a Progress Control 60 Image Lists: Class CImageList 60 CImageList Class Methods 60 Creating and Initializing a CImageList Control 60 List View Controls: Class CListCtrl 60 List View Control Styles 60 Image Lists and the List View Control 60 List View Items and Subitems 60 List View Notification Messages 60 Creating and Initializing a CListCtrl Object 60 Using the List View Control 60 Tree View Controls: Class CTreeCtrl 60 Tree View Control Styles 60 Tree View Notification Messages 60 CTreeCtrl Class Methods 60 Creating and Initializing a Tree View Control 60 Using a CTreeCtrl Object 60 Sample Program: sprers.eu 60 Tab Controls: Class CTabCtrl 60 Tab Control Styles 60 Tab Control Notification Messages 60 CTabCtrl Class Methods 60 The Tab Item Structure (TC_ITEM) 60 Creating and Initializing a Tab Control 60 Using a Tab Control 60 Animate Controls: Class CAnimateCtrl 60 Animate Control Styles 60 Animate Control Notification Messages 60 CAnimateCtrl Class Methods 60 Creating and Initializing an Animate Control 60 Using an Animate Control 60 Rich Edit Controls: Class CRichEditCtrl 60 Rich Edit Control Window Styles 60 The Character Format Structure (CHARFORMAT) 60 The Paragraph Format Structure (PARAFORMAT) 60 CRichEditCtrl Class Methods 60 CRichEditCtrl Line-Related Methods 60 CRichEditCtrl Text-Selection Methods 60 CRichEditCtrl Formatting Methods 60 CRichEditCtrl Editing Methods 60 CRichEditCtrl Clipboard Methods 60

CRichEditCtrl General-Purpose Methods 60 Creating and Initializing a Rich Edit Control 60 Using a Rich Edit Control 60 Summary 60 Painting, Device Contexts, Bitmaps, and Fonts Device Contexts The Graphics Device Interface MFC Wrapping MFC Device Context Classes The Base Class: CDC Painting with Class CPaintDC Managing Client Areas with Class CClientDC Managing Frame Windows with Class CWindowDC Windows Graphic Objects Pens: Class CPen Brushes: Class CBrush Fonts: Class CFont Bitmaps: Class CBitmap Palettes: Class CPalette Regions: Class CRgn GDI Coordinate Systems Logical Mapping Modes Vector Graphics Drawing Modes Lines and Polylines Rectangles Regions Polygons Ellipses Bezier Curves Fonts and Text Font Characteristics The TEXTMETRIC Structure The LOGFONT Structure Font Creation Drawing Text Sample Program: Vector Graphics and Text Methods (sprers.eu) Raster Graphics Named Raster Operations (ROPs) Bitmaps Device-Dependent Bitmaps Device-Independent Bitmaps (DIBs) The CBitmap Class Transferring and Contorting Bitmaps Bitmap Resources Tacking Resources onto an Executable File Getting Image Resources out of an Executable File Sample Program: Exploring Bitmap Resources (BITMAP1) Summary Custom Control Development Window Classes Versus C++ Classes A Validating Edit Control The Clock Static Control Control Metrics

Painting the Face Locating the Hands Painting the Hands Setting the Time Pitfalls of Subclassing Standard Controls The Hyperlink Control Implementation Strategy Font Processing Painting the Window Controlling the Cursor Mouse Input Keyboard Input Launching the Link Advanced Custom Control Topics Subclassing Limitations Notifications Using the Resource Editor with Custom Classes Summary The MFC Application Object, Message Routing, and Idle Processing The MFC Application Object CWinApp and Application Lifetime The CWinApp Data Members The CWinApp Member Functions Application-Specific Initialization Functionality in InitInstance OLE Container Support 3D Look for Windows NT x Registry Usage Most Recently Used Files List SDI and MDI Document/View Main Frame Window Creation Automation Support Rich Edit Control Support Command-Line Handling Message Routing, Message Maps, and Message Categories Message Routing PreTranslateMessage Message Maps Idle Processing OnIdle Idle Processing for Dialogs The Splash Screen Component Summary Documents, Views, and Applications That Use Them The Document/View Architecture Documents, Frames, and Views Document Templates Creating New Documents Opening New Files Single Versus Multiple Document Templates Views The CView Class The CScrollView Class The CFormView Class

The Database View Classes The Control Views Changing Views in an SDI Using the MDI Summary Extending the User Interface Responding to the User Keyboard Messaging Handling Keyboard Messages Mouse Messaging Handling Mouse Messages User Interfaces and AppWizard Extending Menus Obtaining Menus and Pop-up Menus Adding Menu Items Using Floating Pop-up Menus Putting Control Bars to Use Using Toolbars and Rebars Using Status Bars Showing and Hiding Control Bars Supporting ToolTips Updating the User Interface Property Sheets and Wizards MFC's Support for Property Sheets and Wizards Creating a Simple Wizard Splitting a View Summary Printing Printing Fundamentals Printing with MFC Printing in the View The PrintInfo Object Printing Menu Commands Printing and GDI Mapping Modes WYSIWYG Printing Application Resources The Application Class The View Class Pagination Printing with a Known Page Count Printing with an Unknown Page Count Printing Page Numbers Stopping and Aborting Print Jobs Halting a Print Job in OnPrepareDC() Halting a Print Job in OnPrint() Summary MFC and COM Programming COM A Little History Interfaces, Objects, and Methods Some Terminology A Real-World View The IUnknown Interface Servers, Clients, and Classes

Defining the Class Factory How Are COM Objects Reused? Marshaling and Threading Marshaling Threading COM, OLE, and Automation IDispatch Automation Servers, Objects, and Controllers Supporting Both IDispatch and IUnknown Persisting COM Data Structured Storage Identifying COM Data (Monikers) Transferring Data Uniform Data Transfer Connectable Objects DCOM Object Creation Invoking Methods Security Issues Some Important Information BSTR SAFEARRAY HRESULT VARIANT Further Reading Summary COM and MFC Understanding the Afx Global Functions Application Lifetime Control Client Control Management Connection Point Management Control Registration Exceptions Initialization Licensing Type Information Reviewing the OLE Macros Class Factories Client/Container Common Commands Control Property Persistence Dialog Data Exchange Dispatch Maps Event Maps Property Page Data Mapping Property Pages Type Library Access MFC and the OLE Class Categories Active Document Automation Common Dialogs for OLE Container Control Drag and Drop (Universal Data Transfer) The COM Runtime Environment

Document Servers Support Summary MFC OLE Servers Document Servers Server Types Full Server Active Document Container/Server Mini-Server Document Server Design OLE Documents Active Documents Building an Active Document Server Persistence Rendering the View Automation Servers IDispatch GetIDsOfNames GetTypeInfo GetTypeInfoCount Invoke IDispatch-Derived Interface in ODL Calling Methods Through IDispatch GetIDsOfNames Type Information Methods Invoke Dispinterfaces Differ from Interfaces Calling Methods Through IDispatch Dual Interfaces The Variant An Automation Server Using MFC Server Type Declaring and Defining Additional Dispinterfaces Adding Methods and Properties Summary MFC OLE Clients IDispatch and Its Place in Automation Interface Definition for Automation Servers IDL and ATL ODL and MFC Dual Interfaces MFC and Automation Controller Connecting to a Server Server Review Building a Controller Using COleDispatchDriver Using #import Remote Automation Summary MFC ActiveX Controls Development Strategy MFC

ATL MFC and ATL Control Development Two Faces of a Control Runtime Design Time Subclassing a Control MFC ATL

Component Categories ICatRegister ICatInformation Methods, Properties, and Events Properties Methods Events Property Pages Property Pages in ATL Property Pages in MFC Component Registration Registration Scripts Registration and Controls COM Object Subkeys Building an MFC Control Interface Definition A Quick ATL Port Summary MFC ActiveX Control Containers Active Document Container Storage Site Objects In-Place Activation Document Extensions Building the Simplest Active Document Container OLE Controls Adding Containment to an Existing Project ActiveX Container Control Containment and Events Summary Using MFC and ATL What Is ATL and Why Is It Important for Programming in MFC? Helpful ATL COM Support for MFC Applications COM Pointers the Smart Way Other ATL COM Support Advanced ATL Support for MFC Applications Begin with Your MFC Application Add the Required ATL Support Summary Scripting Your MFC Application Scripting Basics Scripting Interfaces Dual Interfaces Object Models Implementing a Scripted Application

Object Implementation Summary MFC Database Programming MFC Database Processing Relational Database Concepts Tables Columns Records Cursors Transactions Storing and Retrieving Data SELECT INSERT DELETE UPDATE Database Communication Mechanisms ODBC DAO Which Methodology Should I Use? ODBC/MFC CDatabase CRecordset DAO CDaoWorkspace CDaoDatabase CDaoRecordset CDaoTableDef CDaoQueryDef Summary Advanced Database Support The COM Approach OLE DB ADO Which One Should I Use? OLE DB Consumers Using the ATL Wrapper Classes CDataSource CSession Accessors Rowsets Accessing Datasource Data Using the ADO C++ Interfaces ADOConnection ADORecordset ADOCommand ADOField ADOProperty ADOParameter ADOError Summary MFC Utility Classes Strings and Collections Strings and String Classes Inside the CString Class Practical CString Usage

File

CString Summary Collections Inside Collection Classes Templated Collections The UNL_MultiEd Application Overview An STL Approach Summary I/O and MFC

Processing Files with CFile Inside the CFile Class The CStdioFile Class The CMemFile Class The CSharedFile Class The CFileDialog Class The User-Defined CFileDialog Class Practical Usage of CFile and CFileDialog Opening a File Reading Data from a File A Classical Approach What Are Streams? Summary Exceptions What Are They Good For? Types of Exceptions Structured Exception Handlers Nesting of Structured Exception Handlers Raising Structured Exceptions Cleaning Up After an Exception C++ Exceptions Defining a C++ Exception Class MFC Exceptions MFC CException-Derived Classes CMemoryException CNotSupportedException CArchiveException CFileException CResourceException COleException CDbException COleDispatchException CUserException CDaoException CInternetException Deriving Your Own MFC-Compliant Exception Objects Deleting Exceptions Using MFC Exception Macros Mixing Exceptions Summary MFC and the Web MFC and DHTML DHTML, MSIE, and the Internet Using the Internet Explorer Web ActiveX Control The CFile Class

Internet Explorer ActiveX Control Basics CHtmlView CHtmlView and the Document/View Relationship CHtmlView and COM Using the Internet Explorer ActiveX Control in a Dialog Box Using DHTML The DHTML Object Model The Document Object Other DHTML Objects Collection Objects DHTML COM Interfaces Obtaining the Document DHTML Interface Obtaining the DHTML Collections Interfaces Using the DHTML Interface The DHTML Element Interface Methods Document Navigation Summary CSocket Programming How Do Network Communications Work? Sockets, Ports, and Addresses Winsock and MFC Initializing the Winsock Environment Creating a Socket Making a Connection Sending and Receiving Messages Closing the Connection Socket Events Controlling Event Triggering Detecting Errors Getting Socket Information Sockets and I/O Serialization Building a Networked Application Creating the Application Shell Window Layout and Startup Functionality Inheriting from the CAsyncSocket Class Connecting the Application Sending and Receiving Ending the Connection Summary WinInet Programming Web Application Protocols and WinInet Hypertext Transfer Protocol File Transfer Protocol Gopher Protocol WinInet API and MFC Internet Session Basics CInternetSession CInternetFile CInternetException CInternetConnection Building a Simple WinInet Application Application-Level Functionality HTTP Classes FTP Classes

Gopher Classes Building a Simple FTP Client Summary ISAPI Extensions The Foundation From There to Here From GET to POST Adding Some Form Elements Change the Form Change the Parse Map Declare and Use the Handler Function Add a Radio Button Other Form Input Elements Change the Form Change the Parse Map Change the Handler Function Summary MAPI and MFC The Messaging Application Programming Interface Client Applications Two Higher-Level Alternatives: Simple MAPI and CMC Simple MAPI Common Messaging Calls The MapiMessage Structure The MapiFileDesc Structure Limited MAPI Functionality in MFC The CDocument Connection Doing MAPI the MFC Way The CDocument::OnFileSendMail() Method Sample Program: sprers.eu Summary TAPE and MFC Overview Assisted Telephony Basic Telephony Service Supplemental Telephony Service Extended Telephony Service History of TAPI TAPI TAPI TAPI TAPI 2 TAPI TAPI TAPI 3 Using Assisted Telephony Using Basic Telephony Configuring TAPI Connecting with TAPI Transmitting Data with TAPI Disconnection with TAPI Terminating a TAPI Session Summary MFC and Graphics Programming

What Is OpenGL? Graphics Boot Camp Core Terms and Key Concepts The Basic Mathematics of Graphics Programming OpenGL Boot Camp OpenGL Datatypes OpenGL Function Naming Conventions OpenGL Render Function Scoping The OpenGL Matrix Stack The OpenGL Rendering Context Minimal OpenGL Program and a Custom View Creating Your Basic MFC Application Adding the Custom OpenGL Base Class Integrate the Custom View Class into Your Application Build Your 3D Scene Add the OpenGL Libraries to Your Project’s Link List 2D and 3D Models Basic Model Development Model Transformations Display Lists Light The Basics of Light in OpenGL Types of Light Object Material Properties Texture Mapping OpenGL Images and Windows Device-Independent Bitmaps Applying Texture Special Effects Blending Fog Summary MFC and DirectX What Is DirectX? DirectX in a Nutshell DirectX Components DirectX Basics Differences in COM Programming Style and DirectX DirectX Component Startup Sequence DirectDraw Basics Initializing DirectDraw DirectDraw and Palettes DirectDraw Surfaces DirectDraw Page Flipping DirectDraw from a Window Using DirectDraw in Practice Surfaces and Bitmaps Windowed Rendering Error Handling DirectDraw Shutdown Summary Multimedia and MFC Multimedia Fundamentals The DirectX Media Player Control MFC and OpenGL

Media Formats Supported by the Media Player Control Inside the Media Player Control The CMediaPlayer Class Using the Media Player Control Playing Sound Working with Waves Revisiting DirectSound Using DirectSound to Play Sound Effects Summary

Advanced MFC

Inside the Registry Registry Usage Configuration Services Information State User Preferences The Registry Structure Programmatic Control of the Registry The Registry API The Registry Sample Application The Registry Key Editor Dialog Creating a New Key Deleting a Key Deleting a Name/Value Pair A Word About Wrapping the Registry Functions A Word About Installation Summary Writing and Using DLLs Advantages of DLLs Code Elimination Modularity and Packaging Extensibility Inside an AFX DLL Exporting Classes, Functions, and Data The Big Deal About Exports Mangled Names Exporting Classes What Goes Around, Comes Around Exporting Explicit Functions Exporting Data Exporting MFC Data Exporting the Destructor Export Toolkit include Files What to Export Other DLL Issues AfxLoadLibrary and AfxFreeLibrary Designing for Extensibility and Reuse Resource Location Multiple Module Definition Files Load Addresses and the Linker Summary Creating Custom Wizards Property Sheets and Property Pages The CPropertySheet and CPropertyPage Classes

The Wizard Walk and the Property Sheet Connection Creating a Wizard Setting the Wizard Mode Enabling the Wizard Buttons Displaying the Wizard Wizard Notification Messages Sample Program: Off to See the Wizard (sprers.eu) Creating Wizard Page Dialog Template Resources Create a Dialog Class for Each Dialog Resource

Index

Exploring the Welcome Page: Class CIntroPage Exploring the About You Page: Class CPage1 Updating Wizard Information for CPage2 and CPage3 Creating and Displaying the Wizard Summary

MFC Programming with Visual C++ 6 Unleashed

Introduction

Introduction If you shop like I do, you’ve just noticed this book on the shelf and picked it up to see what interesting topics it covers. You’ve read the table of contents. Aggressive. There is obviously a lot of detailed MFC information, but there is also a lot of ATL and COM information. Interesting. So you turn to the introduction to see what it has to say about the wealth of information and hard-won experience contained in this (very large) volume. Will it convince you this book is the best MFC programming book on the market today? Absolutely not. If by now you aren’t convinced that this is the best MFC programming book on the market, this introduction won’t sway you. However, this is the best MFC programming book on the market today. Why? Simply because the information contained within these pages represents decades of collective MFC programming experience—not the hobby-shop kind of programming, but rather the hard-core, schedule-pressure, “we need it now” kind of programming. From the basic to the intricate, every page contains more experience per page than any other MFC book out there today. Programmers of all levels will benefit from the information you find here. You don’t understand the Document/View architecture? It’s explained here. You want to extend and go beyond the Document/View architecture? That’s here too, as well as all other aspects of MFC programming. In a nutshell, here is what you’ll find: • • • • • • • • • • • • • • • • • • • •

MFC’s architecture and class layout MFC as C++ MFC as a Windows application programming tool How to create compelling MFC applications Using Developer Studio to create more compelling MFC applications Using the Windows Common Controls from MFC applications Implementing your own custom controls using MFC MFC and the GDI All about MFC’s message routing scheme Documents and views, and how to supercharge their use MFC application user interface programming MFC and printing MFC as a COM server programming platform, including ActiveX programming MFC as a COM client programming platform Adding scripting to your MFC applications MFC and databases MFC’s utility classes, including exception processing MFC and the Web, including DHTML, WinInet, and ISAPI programming MFC and hot graphics programming using both OpenGL and DirectX How to add help access to your MFC applications

It is true that many of these topics can be found in some of the other books you see sitting on the shelf alongside this book. But none of them cover this much information in one place, and each topic here is covered in the deepest detail. After all, that is why the book is titled MFC Programming with Visual C++ 6 Unleashed. 1 /

MFC Programming with Visual C++ 6 Unleashed

Introduction

How This Book Is Organized This book is designed to be the most comprehensive MFC programming resource available anywhere today. As you work from chapter to chapter, you’ll not only learn what makes MFC tick, but you’ll also learn how to supercharge MFC, customize it, and take the architecture and make it work the way you want it to work. You’ll go way beyond the wizard-generated code and see how experienced MFC programmers do their magic. Soon, it’ll be your magic, too: • Part I, “Core MFC,” covers the core MFC concepts. Here, you see how MFC was crafted to be a tremendous general-purpose application framework. When you understand the basic mechanics, you’ll see how to tailor MFC to better fit your programming requirements. Chapter 1 shows you the MFC architecture and introduces you to the major MFC classes you need to understand to get the most from the tool. Chapter 2 initiates your journey through MFC application development by showing you how MFC interacts with data and windows through the use of dialog boxes. Chapter 3 provides the details you need to get the most from the Windows common controls, especially the useful list and tree controls. Chapter 4 shows you how to manage GDI resources using MFC, as well as how you work with fonts, brushes, and so on. After you know how to deal with standard controls and paint screen items, you have what you need to tackle Chapter 5, which shows you how to create custom controls specific to your application. Finally, Chapter 6 dispels the myths surrounding MFC’s idle processing, allowing you to use seemingly idle application processing time to your advantage. • Part II, “Documents, Views, and Applications That Use Them,” details the MFC architecture and how you can both optimize it and modify it to suit your personal needs. Chapter 7 describes the Document/View architecture. Chapter 8 shows you how to extend your application’s user interface. Finally, Chapter 9 blows the cover off using the printer from your MFC application, allowing you to move past the basic wizard-based code to really use the printer. • Part III, “MFC and COM Programming,” describes MFC and COM programming, as most of today’s Windows applications use COM to provide at least some of their functionality. Chapter 10 introduces you to COM, and Chapter 11 provides an explanation of MFC’s implementation of COM. Chapters 12 and 13 discuss OLE servers and clients, and Chapter 14 shows you how to write feature-packed ActiveX controls that the containers you’ll develop in Chapter 15 can use to their advantage. Chapter 16 gives you the facts about mixing MFC and ATL, a templated COM framework. Chapter 17 shows you how to add scripting capabilities to your MFC applications. • Part IV, “MFC Database Programming,” shows you how MFC and databases work together. Chapter 18 looks at MFC and various database programming concepts and technologies. Chapter 19 moves past the basics and shows you the current technologies in MFC (and COM) database processing. • Part V, “MFC Utility Classes,” nails down the details regarding the MFC utility classes. Chapter 20 covers MFC string and collection management. Chapter 21 shows you how to work with files using MFC. Chapter 22 provides the critical details you need to process exceptional runtime conditions. • Part VI, “MFC and the Web,” marries MFC and the Web. Chapter 23 introduces you to Dynamic HTML (DHTML) and how you can access DHTML from your MFC application. Chapter 24 shows you the basics of MFC network programming. Chapter 25 moves to advanced MFC network programming. Chapter 26 describes MFC ISAPI 2 /

MFC Programming with Visual C++ 6 Unleashed

Introduction

programming. Need to add telephonic or electronic mail support to your MFC application? Then Chapters 27 and 28 are here for you. • Part VII, “MFC and Graphics Programming,” introduces you to the fascinating area of MFC graphics programming. Chapter 29 describes OpenGL and how you can exploit that technology in your MFC applications. Chapter 30 similarly describes MFC and DirectX. Chapter 31 goes a step further by adding full-fledged multimedia support to your MFC applications. • Part VIII, “Advanced MFC,” gives you a wealth of insight born of experience. Chapter 32 shows you how to work with the Windows Registry database. Chapter 33 describes using MFC from within DLLs. And the final chapter, Chapter 34breaks open the secrets of Developer Studio AppWizard programming. Who Should Read This Book? Actually, this book is perfect for just about anyone interested in programming Windows applications using MFC. Whether you are just beginning or have weathered MFC programming from its inception, there are valuable nuggets for you here: Beginners—The basic concepts are clearly and concisely covered. More important than that, however, is the valuable coverage you’ll find regarding pitfalls and potential optimizations. You’ll learn the basics, but you’ll also learn how to avoid common beginning MFC programmer mistakes. Casual and accomplished MFC programmers—Use this book as a reference to delve into topics of specific interest. You will be able to reuse much of the code you find here to enhance your ongoing Windows programming tasks. You’ll also find detailed coverage of the latest Microsoft technologies with specific use from within MFCbased applications. Experts—For you, this book provides the detailed programmer-to-programmer information you won’t find elsewhere. Our goal was to provide you with the deepest details and provide alternative methods of accomplishing intricate programming tasks. If you need it, it’s here for you. We have worked exceptionally hard to provide you with the definitive work to date regarding MFC programming. Enjoy!

3 /

MFC Programming with Visual C++ 6 Unleashed

Foreword

Foreword The Microsoft Foundation Classes are a excellent example of how an object-oriented approach to packaging software functionality can lead to code reuse, reduced application complexity, and in the end, a more efficient software development environment. MFC has been around for about seven years now. The first version of MFC was released with version 7 of Microsoft’s bit C/C++ compiler, and it represented little more than a wrapper around the Window GDI calls. (Visual C++ version 1 followed Microsoft C/C++ version 7.) For those who had been developing applications using the Windows API, MFC promised an immense gain in programming productivity. Rather than write Petzold-style WinMain procedures, message loops, and switch statements to dispatch messages, you could create an instance of a class that would take care of much of the drudgery. Rather than create GDI objects, write many lines of code to initialize and use the objects, carefully track their lifetimes, and be sure to release them properly, you could instantiate an MFC class, often simply use the default values, and then let the destructor worry about cleaning up system resources. Indeed, to truly comprehend the advantages of using MFC, you should write a significant graphics application first using MFC and then using strictly the Windows API. Then compare war stories. But although MFC made the programmer’s life easier, early versions were not without cost. MFC applications were much larger than a non-MFC equivalent. They tended to run slower as well (probably because they were so much larger). And whenever it was necessary to stretch the MFC envelope a bit, a working knowledge of the Windows API was still a prerequisite. MFC has gone through many iterations since version 1 was released. The current revision of MFC is version 6. MFC added the Document/View architecture in version 2, ODBC and drag-and-drop support in version , and multithreading and Unicode support in version 3. Subsequent releases have added support for socket classes, Internet classes, OLE automation, and thread synchronization. MFC has constantly evolved in its support of new graphic interface features and now offers a rich collection of support classes such as arrays, lists, and strings, to name a few. Over the years, I’ve used MFC on many projects. One of the most rewarding of those endeavors was being part of the software development team for Qualcomm’s Eudora versions 3 and 4. We used MFC extensively in the creation of the Windows version of that product. The real world still holds challenges for programmers! MFC has not changed that; MFC is still supplied with source code for good reason. But without MFC, I believe developing Eudora would have been a much more difficult and time-consuming task. MFC allowed us to build a product that conformed to Windows GUI standards, incorporated new and improved user interface metaphors, and ran with a high degree of independence on many versions of operating systems and hardware platforms. MFC also saved time when constructing non-GUI data structures and objects used by the internals of Eudora. 4 /

MFC Programming with Visual C++ 6 Unleashed

Foreword

This book is an authoritative reference document that describes MFC: what it is and how to get the most out of it. This book is written by programmers for programmers. It is filled with sample applications and code snippets to clarify and demonstrate the use of MFC 6. If you are new to MFC, this book will get you up to speed quickly. If you are familiar with MFC but need to drill down into the details of a specific MFC class, this book will be quite valuable as well. This book can also be used as a companion to the Microsoft documentation, which is typically quite good but perhaps a bit terse in spots. I hope you find this book both educational and enjoyable. Keith McIntyre Vice President—Engineering Internet Systems Division Stellcom, Inc.

5 /

MFC Programming with Visual C++ 6 Unleashed

About the Author

About the Authors Eugene Olafsen has been working with Microsoft Windows since the release. At that time, he was attempting to build a product using Digital Research’s GEM (Graphics Environment Manager), decided to port to Windows, and has never looked back. He has worked with MFC/OLE since its humble beginnings. Gene has worked to develop applications ranging from engine test simulators for Boeing to search and publishing systems for Reuters. He is an independent consultant and a principal partner in Stratton & Associates, Ltd. (sprers.eu), a software-engineering firm. His current projects include application development that leverages COM and Web technologies. Kenn Scribner actually began his career in computers in as a pizzeria manager. After he realized he didn’t want to make pizzas for a living, he joined the Air Force as a computer operator. Two degrees and a commission later, he found himself designing silicon-based Fast Fourier Transform processors and running a research flight simulation facility. As the Air Force downsized, he retired and began writing Windows applications. (He’s delighted to earn a living with his previous hobby!) Kenn has written several commercial Windows applications, and he now finds himself writing all the client user interface code and major ATL-based COM components for a large-scale n-tier client/server application. Kenn also started his own company, the EnduraSoft Corporation (sprers.eu), writes the “Windows Programming” column for “TechTalk” —the newsletter of the Small Computer Book Club (sprers.eu)—and acts as a Windows programming technical reviewer for several publishers. In his dwindling spare time, Kenn enjoys the company of his lovely wife and two wonderful children, works with his horse, remodels parts of his house, and generally acts as EnduraSoft’s chief groundskeeper. Kenn can be reached at [email&#;protected] K. David White has been developing software since , using a wide variety of products, platforms, and languages. During this time, Dave implemented several systems, ranging from a facilities security system based on DEC MACRO to several large supervisory control systems in the oil industry on DEC VMS. Seeing the handwriting on the wall in , Dave started developing Windows-based software using Microsoft C and C++. Since that time, Dave has produced several MFC-based products and is currently developing ATL COM objects. Dave also contributed to the Sams book Sams Teach Yourself Database Programming with Visual C++ in 21 Days. In what little spare time that Dave has, he thoroughly enjoys woodworking, golf, singing, and spending time with his wife and three kids. Dave can be reached through email at [email&#;protected] Contributing Authors Michael Morrison is a writer, developer, toy inventor, and author of a variety of books including Sams Teach Yourself MFC in 24 Hours (Sams Publishing, ), Windows 95 Game Developer’s Guide Using the Game SDK (Sams Publishing, ), Complete Idiot’s Guide to Java (Que Corporation, ), and Java Unleashed (Sams Publishing, ). Michael is also the instructor of several Web-based courses, including DigitalThink’s Win32 Programming series, the Introduction to Java 2 series, and the JavaBeans for Programmers series. Michael cut his teeth on Windows programming by codeveloping one of the first action games for Windows, Combat Tanks. When not glued to his computer, risking life and limb on his skateboard, or watching movies with his wife, Mahsheed, Michael enjoys hanging out by his koi pond. 6 /

MFC Programming with Visual C++ 6 Unleashed

About the Author

Davis Chapman first began programming computers while working on his master’s degree in music composition. Writing applications for computer music, he discovered that he enjoyed designing and developing computer software. It wasn’t long before he came to the realization that he stood a much better chance of eating if he stuck with his new-found skill and demoted his hard-earned status as a “starving artist” to a part-time hobby. Since that time, Davis has focused on the art of software design and development, with a strong emphasis on the practical application of client/server technology. Davis is the lead author of Sams Teach Yourself Visual C ++ 6 in 21 Days, Web Development with Visual Basic 5, and Building Internet Applications with Delphi 2 . Davis is also a contributing author on Special Edition Using Active Server Pages and Running a Perfect Web Site, Second Edition. He has been a consultant working and living in Dallas, Texas, for the past ten years and can be reached at [email&#;protected] David Lowndes is a senior software developer at Boldon James Ltd. A Microsoft MVP since , Davis is a frequent contributor to the sprers.eu newsgroups, helping with Visual C++ and general Win32 issues. When not programming, he can be found playing guitar and trying to muscle in on his son’s band. David can be contacted at [email&#;protected] Bill Heyman is an independent software consultant who specializes in systems and applications software development using Microsoft Visual C++ and MFC Windows platforms. As a ten-year software development veteran who has provided software engineering services for IBM and Andersen Consulting, Bill has experience in DOS, OS/2, Windows, UNIX, and PalmOS. For more information, including consultation for your own project, visit Bill at his Web site, sprers.eu~heyman/. His email address is [email&#;protected] Ed Harris is the lead engineer for tools and components development at NetPro Computing, Inc. His group designs reusable frameworks for distributed network and directory service monitoring on both Win32 and NetWare networks. Previous to that, Ed spent eight years as a Visual C, Windows, and MFC consultant, specializing in the unlikely combination of custom control development and mouse drivers. When not developing software, Ed enjoys spending time with his fiancée, Angela, flying airplanes, and playing basketball. Ed can be contacted at [email&#;protected] Keith McIntyre has been developing software since the days of 4-bit processors. He has watched and participated in the personal computer, local area network, client/server, and Internet evolutions. During his years as a consultant/contract engineer, Keith has worked on a myriad of technologies, including turbine engineer control systems, satellite communication systems, tape drive firmware, UNIX and Windows device drivers, imaging and document management software, and custom application development. Keith has contributed to many shrink-wrap software products including those published by Optigraphics, Emerald Systems, Compton’s New Media, and Qualcomm. Keith is currently vice president of engineering for Stellcom’s Internet Systems division. Keith McIntyre holds a B.S. in Computer Science. Rob McGregor began exploring computer programming in BASIC as a teenager in Since then, Rob has worked as a programmer, software consultant, and 3D computer artist; he has written a variety of programs for Microsoft and numerous other companies. Rob lives in Rockledge, Florida, and in his free time, enjoys ray tracing, reading, writing, and playing guitar. You can contact Rob via email at [email&#;protected] 7 /

MFC Programming with Visual C++ 6 Unleashed

About the Author

Acknowledgments I would like to thank Chris Webb at Macmillan for his advice and support throughout my involvement with this book. Additionally, I cannot praise the various editors and individuals involved in production enough for their input and the value they add to this project. I would like to thank Hub and Simon at TSCentral for their flexible working arrangements during the final push to complete this text. Thanks to John Penrose of Progressive Technologies for his late-night calls, reminding me that I’m not the only one up working. Thanks to my brother Stephen for getting my network running and answering my NT Server administration questions. Thanks also to my friends at Reuters, especially Steve, Dave, Ray, Joe, and Ed. Finally, I must acknowledge Gina for her tireless code reviews throughout the years. —Gene Olafsen If there was a time not to write a book, it was while I was writing this one. My wife was studying for medical school entrance, my current project at work wanted to consume all my time and then some, and my children were very, very young (miss a day and you miss a lot). I couldn’t forget to thank them for their sacrifice so that I could make this effort. I would also like to thank the terrific team at MCP, especially Chris Webb, who put up with this cranky author. (I was, too; just ask him.) I would like to extend most heartfelt thanks to Keith Davenport, Dana Lesh, and Margaret Berson, all at MCP. It was they who had to read my raw material and fire it in the crucible of experience to produce the fine product you hold in your hands. And thanks to the nameless (to me) crew, who tirelessly set the type, adjusted the margins, and actually put my words to paper. From experience, I know it’s not a small task. Finally, thanks to you for taking the time to look over my work and find it worthy of your hard-earned dollar. I hope you enjoy reading it and find it tremendously useful in your daily work. —Kenn Scribner There are so many people that have been supportive through the writing of this book. I want to thank Chris Webb of Macmillan Publishing for being extremely patient during this ordeal. Writing a book about a topic that has a plethora of coverage already is no easy task. Coupling that with the demands of a job and family leads to very long nights and extended schedules. Even though the publishing deadlines loomed large in the rear-view mirror, Chris remained supportive during the entire effort. He was also responsible for tracking down contributing authors. Another person that needs recognition is my mother. I would like to thank her for helping me through school all those years ago. Her sacrifices to her family have paid off in dividends that cannot be described by mere words. Thanks, Mom! I would also like to thank Kenn Scribner for his contribution to this effort and his insight into helping me put together the table of contents. His daily support and encouragement helped me cope with the daily pressures. If you need an ActiveX guru, Kenn is your man! But, most of all, I want to thank the love of my life, my wife, for allowing me to put myself into this work. The late nights and missed opportunities can never be regained, and I just want to tell my family how much I love them! —K. David White Dedication To my wife, Donna, for her love, encouragement, and understanding—and to my 8 /

MFC Programming with Visual C++ 6 Unleashed

About the Author

children, Ashley and Eric, for the insight and wisdom they offer, beyond their years. —Gene Olafsen This, my first book, is lovingly dedicated to my wife, Judi, and to my children, Aaron and Katie. —Kenn Scribner Tell Us What You Think! As the reader of this book, you are our most important critic and commentator. We value your opinion and want to know what we’re doing right, what we could do better, what areas you’d like to see us publish in, and any other words of wisdom you’re willing to pass our way. As an associate publisher for Sams Publishing, I welcome your comments. You can fax, email, or write me directly to let me know what you did or didn’t like about this book—as well as what we can do to make our books stronger. Please note that I cannot help you with technical problems related to the topic of this book, and that due to the high volume of mail I receive, I might not be able to reply to every message. When you write, please be sure to include this book’s title and author as well as your name and phone or fax number. I will carefully review your comments and share them with the author and editors who worked on the book. Fax: Email: Mail:

() [email&#;protected] Bradley L. Jones Associate Publisher Sams Publishing West rd Street Indianapolis, IN USA

9 /

MFC Programming with Visual C++ 6 Unleashed

Summary

Part I Core MFC In This Part • • • • • •

The MFC Architecture 7 MFC Dialogs, Controls, and Data Interaction 49 The Windows Common Controls 79 Painting, Device Contexts, Bitmaps, and Fonts Custom Control Development The MFC Application Object, Message Routing, and Idle Processing

Chapter 1 The MFC Architecture by Bill Heyman In This Chapter • A Brief History of MFC 8 • The MFC Class Hierarchy 13 The Microsoft Foundation Classes (MFC) allow you to develop C++ GUI applications for Windows using its rich set of classes. This chapter discusses the evolution of MFC and the fundamental classes used in almost every MFC-based application. A Brief History of MFC Since its beginnings in , Windows has introduced legions of traditional DOS programmers to a new way of programming: a device-independent, event-driven model. Although the Windows API has grown to add much new functionality, it still retains the basic functions that existed in the early versions of Windows (such as Windows/ and Windows/). In the late s, BASIC, assembler, and Pascal were the lingua francae for DOS software development. At this time, the C language was starting to grow beyond its UNIX roots and become a high-performance, systems development language on other platforms. Microsoft’s choice of using C (combined with assembler) for the development of Windows allowed C to gain a foothold among the PC developers. The original Windows API (now sometimes called Win16) catered to using a C development environment. The American National Standards Institute (ANSI) standardized the C language in , thus solidifying C as a language for application and systems development. Armed with the Windows Software Development Kit (SDK) and the Microsoft C compiler, developers started developing GUI applications that took advantage of the Windows API. The C language was procedural—it had no built-in support for the object-oriented features that are commonly used today: encapsulation, inheritance, and polymorphism. The Windows API was designed and delivered as a procedure-based interface and, hence, was perfect for the development technology of the time. However, as object-oriented extensions to C were developed and more widely accepted in a new language called C++, an object-oriented wrapper interface to the Windows API seemed a natural next step. Microsoft developed this interface as its Application Frameworks (AFX) product in This evolved into the Microsoft Foundation Classes (MFC) product that exists today. Note: The Windows API is object-based. This means that you can programmatically interact with the system objects (such as windows, semaphores, and pens) through a handle and a defined interface. The actual implementation and data used by the implementation is hidden from the view of the program. This “data hiding” is called encapsulation. The MFC Class Libraries are object-oriented. This means that in addition to the encapsulation, the interfaces (packaged in a set of C++ classes) also provide inheritance and polymorphism. Inheritance is the capability to share and extend the functionality of an existing class. Polymorphism is the capability of objects to support the same interface, but provide different implementations.

10 /

MFC Programming with Visual C++ 6 Unleashed

Summary

Note: Although the Windows API is procedural and designed to be called from procedural languages (like C), you can (and will) use the Windows API directly from your MFC applications written in C++. The concept of device independence was a boon for both software developers and hardware manufacturers (well, at least the manufacturers that didn’t have a great amount of market share at the time). Unlike the traditional DOS programs that required specific routines for different video and print devices, programs coded for Windows could be written to a common interface and work across a wide variety of video and print devices. The result is that developers could focus more on the problem on hand, rather than the hardware used to solve the problem; and manufacturers could focus more on creating device drivers for Windows and allow a much wider variety of software that can use their devices. Concomitant with the move to device independence, Windows GUI development forced a paradigm shift on the traditional DOS programmers. At that time, most software was written in a procedural manner: one function calling another, with the main program always being in control. The event-driven model forced programs to give up their total control and, instead, wait and respond to external events to provide their functionality to the end users. The structure of Win16 (and now Win32) GUI programs remains the same today as it was in Figure shows the basic structure of a Windows GUI application. Observe that each program consists of an entry point, the creation of a main window, a message loop, and the destruction of the main window. In addition, there is a function associated with the main window, called a window procedure, which contains the code that handles the system and application events (such as keyboard entry, mouse movement and clicks, timer alarms, menu selections, and pushbutton clicks).

Figure Structure of a Windows GUI application. The entry point of a Windows GUI program is called WinMain. Named similarly to the entry point of C programs, main, every Windows GUI application must provide a WinMain function. Unlike main, it is passed different parameters and is declared as follows in Win32 programs: int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd);

The four parameters to the WinMain function include two handles (HINSTANCE), a pointer to a string (LPSTR), and an integer (int). The instance handle represents a unique application identifier for the program’s main executable file in memory. The previous instance handle is no longer used in Win32 and is always equal to zero. The pointer to a string contains the command-line arguments passed to the program at start time. Finally, the integer contains an integer value that the program is supposed to pass to the ShowWindow function that indicates whether the main window is to appear minimized, maximized, or normal. Note: A handle is simply a or bit value that uniquely identifies a system object to an application. By exposing only the handle of a system object, Windows can hide (encapsulate) that object’s implementation and data and provide a controllable interface to that system object. This allows Microsoft to add more functionality to existing system objects, yet still support old applications—as long as they do not change the behavior of the existing interfaces. (Occasionally some interface’s behavior does change between releases. This often is the exception rather than the rule.) The most basic C++ classes in MFC wrap the handles to the Windows system objects: windows, device contexts, pens, and brushes, to name a few. Because it needs to perform a great deal of initialization at program startup and it provides an object-oriented interface to the Windows API, MFC provides a WinMain function for your application. The MFC-provided WinMain calls another function, AfxWinMain, which

11 /

MFC Programming with Visual C++ 6 Unleashed your application. The MFC-provided WinMain calls another function, AfxWinMain, which

Summary

creates and manages your CWinApp-derived application object. If you need to perform application-specific initialization, run handling, and/or termination, refer to the more detailed discussion of the CWinApp class and CWinApp::InitInstance, CWinApp::Run, and CWinApp::ExitInstance methods later in this chapter.

Without a main window, an application wouldn’t have a graphical user interface and would find it hard to respond to window-related events. Consequently, almost all Windows GUI applications create a main window as their first order of business when starting. Using direct calls to the Win32 API, your application calls RegisterClass to register a window class (basically associating a name with a window event callback function), followed by CreateWindowEx, to create a main window (which is an instance of the registered window class). In MFC, this work is done “automagically” when Visual Studio generates the code for you. Generally, in generated code, your main frame’s application window is created in the CWinApp::InitInstance code. The next basic feature required for every Windows application is the message loop. Typically in programs that call the Windows API directly, this is accomplished as shown following: MSG msg; while (GetMessage(&msg, 0, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); }

This loop allows the current application thread to get system events that are queued up for windows created by that thread. The GetMessage function returns a Boolean value TRUE for all messages, except the WM_QUIT message, which allows the while loop to end, due to application termination. After the call to GetMessage returns with a message (event) for one of the thread’s windows, that thread calls TranslateMessage, to process any accelerator keys and menu hot keys, followed by DispatchMessage, to send the message to the window to which it belongs by calling that window’s registered window procedure. What Is a Thread You are probably intimately familiar with the concept of a process. In many operating systems, a process corresponds to an instance of executing code in the computer’s memory. Processes contain memory (usually some for code and some for data) and open resources, such as files, pipes, and other system objects. Traditionally, many operating systems had the current execution state (current machine registers, including the instruction pointer, and a stack) associated with the process. As a result, each process was treated as a single unit of execution when the operating system shared the CPU via multitasking. Windows and many other modern operating systems allow multiple units of execution within the same process. Each unit of execution is called a thread. Each thread within a process has the same access to all the memory and resources owned by the process. However, each thread maintains its own copy of the machine registers and call stack. Threads are often used to perform some operation “concurrently” within the process and provide a simpler and more efficient mechanism as compared to creating or “forking” a new process. (Actually, on a uniprocessor system, threads cannot literally run at the same time; however, on a multiprocessor system they actually could run simultaneously.) Another advantage of threads is that they enable you to separate logical units of code and maximize throughput in your programs. For example, if one thread is waiting for (blocking) a file I/O request, another thread could perform some mathematical calculation, and yet another thread can handle user interface events. The end result is that the program’s overall performance can be improved because its utilization of the CPU(s) is maximized for a given amount of time. For MFC applications, once again the message loop is automatically included as part of your application. In the case of Single Document Interface (SDI) and Multiple Document Interface (MDI) applications, this message loop is put into control through the CWinApp::Run method. (More specifically, CWinApp::Run calls the CWinThread::Run method, which is in its base class.) For dialog-based applications, the message loop is instantiated during the CWinApp::initInstance through a call to CDialog::doModal. In

12 /

MFC Programming with Visual C++ 6 Unleashed

Summary

addition, when messages are dispatched from the thread’s message loop, they are routed through the standard MFC-owned window procedures (AfxWndProcBase and AfxWndProc) and finally mapped to a function within your window or dialog class. (This process will be explained in more detail later in this chapter.) The final phase of a typical Windows program’s WinMain function is the destruction of the main window via a call to the DestroyWindow function. Of course, this is also part of the MFC code that your application uses. If you need to do termination processing in your application, you would override the CWinApp::ExitInstance method in your application’s CWinApp-derived class. At this point you should have a basic understanding of how some of the more basic features of a standard Windows API application correlate to an MFC application. From this point forward, the discussions will leave the Windows API behind and deal with the features of MFC. Of course, specific Windows APIs might be mentioned from time to time, but not as a major part of any section in this book. The MFC Class Hierarchy So far several MFC classes have been mentioned. This section covers some of the more important classes that make up the MFC architecture. Figure shows the inheritance hierarchy of some of the most important application architectural classes within MFC. You might immediately observe that these classes all ultimately derive from a class named CObject.

Figure MFC architecture class hierarchy. CObject The CObject class is the “mother of all MFC classes.” Well, actually not quite all MFC classes, but quite a few of them. Its primary responsibilities are to support handle runtime type information and object persistence (or serialization in MFC-speak), and to perform diagnostic output for derived objects. Classes that are derived from the CObject class can support its features in one of four ways: 1. (Most basic) General diagnostic support. 2. (Dynamic) All features described thus far plus runtime type identification. 3. (DynCreate) All features thus far plus the capability of unbound dynamic object creation. That is, the class can be constructed by code that does not know the class’s name at the time it was compiled and linked. 4. (Serial) All features thus far plus the capability of storing and restoring instances of the object to and from a byte stream. Diagnostic Support (All CObject-Derived Classes) The diagnostic support within the CObject class is limited to two methods: AssertValid and Dump. Each of these methods can be called at any time from your derived class.

AssertValid The AssertValid method allows a class to perform a sanity check on itself before continuing. It is declared as a public method in the CObject class as follows: virtual void AssertValid() const;

If you choose to override this method, you will typically use the ASSERT macro to perform sanity checks on your object’s data. In addition, you should call your base class’s implementation of this method so it can also validate its data. Because this method is

13 /

MFC Programming with Visual C++ 6 Unleashed

Summary

const, you cannot change your object’s state from within this method. Caution: Do not depend on AssertValid working in release code. This is because the ASSERT macro is only defined when _DEBUG is defined at compilation time. Because it is a public method, you can call it either from inside your class or from outside your class at any time. Dump The Dump method allows a class to put diagnostic information in the human-readable form of text and/or numbers to a stream, typically through the OutputDebugString API, which displays it in the debugger’s output window (or any other program that traps debug strings). It is declared as a public method in the CObject class as follows: virtual void Dump(CDumpContext& dc) const;

If you override this method, first call your base class’s dump method. Next, call the insertion operator (>) to retrieve data from the data stream. Likewise, if it is in storing mode, you can use its insertion operators (uFlags & TTF_IDISHWND) { UINT idCtrl = ::GetDlgCtrlID(HWND(pTTT->sprers.eu)); if (idCtrl == IDC_PB_CUSTOM_MODELESS && m_custDlg.m_hWnd) { pTTT->lpszText = MAKEINTRESOURCE(IDS_TT_PB_CUSTOM_MODELESS2); } else { pTTT->lpszText = MAKEINTRESOURCE(idCtrl); } pTTT->hinst

= AfxGetResourceHandle();

return TRUE; } return FALSE; }

Listing demonstrates how to add custom logic to dynamically change the actual ToolTip text according to the current state of the application. In MFCSample, generally all ToolTips are loaded from string resources where the string resource identifier is equal to the control identifier. However, if a modeless dialog is currently displayed, the ToolTip for the custom modeless pushbutton changes accordingly. Dialog Data Exchange Dialog Data Exchange is a powerful means of associating non-control datatypes with controls. When DDX is used, your application logic can deal with the data itself, rather than the controls to get and set the data. The “Interacting with Controls” section discussed associating a control-type member variable with a control. With DDX, you can associate a data member variable with a control. For example, rather than having an m_edMyText CEditBox member variable, you can have an m_myText CString member variable. Furthermore, using a DDX method named UpdateData, your application can always ensure that the data member variable and actual control remain in sync. Standard DDX 54 /

MFC Programming with Visual C++ 6 Unleashed

Summary

When you create a non-control member variable that is associated with a control, Visual Studio generates code to initialize and associate the data member and the control. The MFCSample application has one member variable, m_fileName, which is associated with a static text control to display its data. Upon creating the member variable (as discussed in “Interacting with Controls”), Visual Studio creates initialization code for those data members in the class’s constructor, as shown earlier in Listing Additionally, it creates a method named DoDataExchange that exchanges the data between the control and the data member (and vice versa). For the MFCSample application, this method is shown in Listing Listing DDX Method DoDataExchange in MFCSample void CMFCSampleDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMFCSampleDlg) DDX_Control(pDX, IDC_ST_COLOR, m_stColor); DDX_Control(pDX, IDC_PB_CUSTOM_MODELESS, m_pbCustomModeless); DDX_Control(pDX, IDC_ST_FONT, m_stFont); DDX_Text(pDX, IDC_ST_FILE, m_fileName); //}}AFX_DATA_MAP }

In the DoDataExchange method for the CMFCSampleDlg class, four DDX associations are implemented. The first three associate the dialog control with the control-type member variable that references it. In this way, IDC_ST_COLOR is associated with m_stColor, IDC_PB_CUSTOM_MODELESS is associated with m_pbCustomModeless, and IDC_ST_FONT is associated with m_stFont. The fourth association is between a control and a data member variable: IDC_ST_FILE and m_fileName. UpdateData The UpdateData method is what keeps all of the DDX associations in sync. Using this method, you can force the data to go either from the control to the member variable or vice versa, based upon the passed parameter. This UpdateData method is declared as follows in the CWnd class: BOOL UpdateData(BOOL bSaveAndValidate = TRUE);

If you pass TRUE as the parameter to UpdateData, the data moves from the controls to their associated data members. Passing FALSE does the reverse. If an error occurs due to a data validation error, FALSE is returned from this method. Using Standard Dialog Boxes MFC provides four standard dialog boxes that allow your application to get information from the user in a way consistent with other applications. These dialogs are the file open/save dialog, the color selector, the font selector, and the print configuration dialog. File Open/Save The MFC CFileDialog class represents the File Open/Save dialog. By instantiating an 55 /

MFC Programming with Visual C++ 6 Unleashed

Summary

object from this class, your application can prompt the user for a filename to open or save. The File Open dialog is shown in Figure

Figure The Windows standard File Open dialog. The MFCSample application displays the File Open dialog when the user clicks the File button. If the user selects a file and clicks OK, that file is displayed in the main dialog. The code to support this use is shown in Listing Listing Simple Code to Display the File Open Dialog void CMFCSampleDlg::OnPbFile() { CFileDialog fileDlg(TRUE); if (sprers.eul() == IDOK) { m_fileName = sprers.eueName(); UpdateData(FALSE); } }

Color Selector The MFC CColorDialog class represents the Color selection dialog. By instantiating an object from this class, your application can prompt the user for a color. The Color selection dialog is shown in Figure

Figure The Windows standard Color selection dialog. The MFCSample application displays the Color Selection dialog when the user clicks the 56 /

MFC Programming with Visual C++ 6 Unleashed

Summary

Color button. If the user selects a color and clicks OK, that color is displayed in the main dialog. The code to support this use is shown in Listing Listing Simple Code to Display the Color Selection Dialog void CMFCSampleDlg::OnPbColor() { CColorDialog colorDlg(m_currentColor); if (sprers.eul() == IDOK) { m_currentColor = sprers.euor(); DrawBitmapWithColor(); } }

Font Selector The MFC CFontDialog class represents the Font selection dialog. By instantiating an object from this class, your application can prompt the user for a font face, size, and style. The Font selection dialog is shown in Figure The MFCSample application displays the Font Selection dialog when the user clicks the Font butn. If the user selects a font face, size, and style and clicks OK, that font is used to draw some sample text that is displayed in the main dialog. The code to support this use is shown in Listing

Figure The Windows standard Font selection dialog. Listing Simple Code to Display the Font Selection Dialog void CMFCSampleDlg::OnPbFont() { CFontDialog fontDlg; if (sprers.eul() == IDOK) { CFont font; LOGFONT logFont; sprers.eurentFont(&logFont); 57 /

MFC Programming with Visual C++ 6 Unleashed

Summary

sprers.euFontIndirect(&logFont); m_sprers.eut(&font); } }

Print Dialog The MFC CPrintDialog class represents the Print selection dialog. By instantiating an object from this class, your application can prompt the user for a printer. The Print selection dialog is shown in Figure The MFCSample application displays the Printer Selection dialog when the user clicks the Print button. If the user selects a printer and clicks OK, a sample page is printed on that printer. The code to support this use is shown in Listing Listing Simple Code to Display the Printer Selection Dialog void CMFCSampleDlg::OnPbPrint() { CPrintDialog printDlg(FALSE); if (sprers.eul() == IDOK) { CDC printerDC; sprers.eu(sprers.eunterDC()); int cx = sprers.euiceCaps(PHYSICALWIDTH); int cy = sprers.euiceCaps(PHYSICALHEIGHT); // add printing logic here sprers.euoc(“MFCSample Document”); sprers.euage(); DrawClock(printerDC, __min(cx, cy)); sprers.eue(); sprers.eu(); CString msg = “Printed to: ”; msg += sprers.euiceName(); MessageBox(msg); } }

58 /

MFC Programming with Visual C++ 6 Unleashed

Summary

Figure The Windows standard Print selection dialog. Summary Microsoft Visual Studio’s AppWizard makes creating a simple dialog-based MFC application easy. After you have followed the AppWizard through its steps and have generated an application shell, you can add your application’s functionality in a relatively straightforward manner. Additionally, the Visual Studio resource editor enables you to add standard controls to your application—from basic controls such as pushbuttons and list boxes to the newer, more specialized controls such as the hot key control and IP address control. You can use one of standard selection dialogs to prompt the user for a file, printer, color, and font at the appropriate places within your application. The MFC architecture provides a standard mechanism, Dynamic Data Exchange, for interchanging data between variables and your dialog’s controls. When equipped with DDX support, your application’s dialogs can validate and transfer user input to your dialog in a well-designed manner. For more information on programming the dialog controls, see Chapter 3.

59 /

MFC Programming with Visual C++ 6 Unleashed

Summary

Chapter 3 The Windows Common Controls by Rob McGregor In This Chapter • • • • • • • • • • • • •

Initializing and Using the Common Controls 80 Notifications for Windows Common Controls 81 Hot Key Controls: Class CHotKeyCtrl 85 Spin Controls: Class CSpinButtonCtrl 88 Slider Controls: Class CSliderCtrl 95 Progress Bar Controls: Class CProgressCtrl Image Lists: Class CImageList List View Controls: Class CListCtrl List View Items and Subitems Tree View Controls: Class CTreeCtrl Tab Controls: Class CTabCtrl Animate Controls: Class CanimateCtrl Rich Edit Controls: Class CRichEditCtrl

Windows controls, those doodads and widgets that make the Windows GUI so appealing, include both the Windows standard controls and the Windows common controls. The Windows standard controls include list boxes, edit boxes, combo boxes, scrollbars, and various types of buttons. The Windows common controls were introduced with Windows 95, and they add a lot of additional GUI power to the Windows programmer’s toolkit. Because the common controls are specific to Win32, the MFC common control classes are available only to programs running under Windows 95 or later, Windows NT version or later, and Windows x with Win32s or later. Initializing and Using the Common Controls Before you can use any of the Windows common controls in your applications, you must initialize the common control DLLs with a Win32 API function call. Windows 95 applications use the InitCommonControls() function to register and initialize all the common control window classes. Its use is easy, as you can see by its function prototype: void InitCommonControls(VOID);

The InitCommonControls() function is now obsolete; it has been replaced with the more intelligent InitCommonControlsEx() function, which loads only the specific control classes that you specify. Its function prototype looks like this: BOOL InitCommonControlsEx(LPINITCOMMONCONTROLSEX lpInitCtrls);

InitCommonControlsEx() registers specific common control classes, specified by the parameter lpInitCtrls, from the common control dynamic-link library (DLL). The lpInitCtrls parameter is of type LPINITCOMMONCONTROLSEX, which is a structure containing information about which control classes to load from the common control DLL. The INITCOMMONCONTROLSEX structure looks like this: typedef struct tagINITCOMMONCONTROLSEX 60 /

MFC Programming with Visual C++ 6 Unleashed

Summary

{ DWORD dwSize; DWORD dwICC; } INITCOMMONCONTROLSEX, *LPINITCOMMONCONTROLSEX;

The parameters are as follows: • dwSize The size of the structure, in bytes. • dwICC The set of bit flags that specifies which common control classes to load from the common control DLL. This parameter can be any combination of the values in Table Table The Bit Flags Used by the INITCOMMONCONTROLSEX Structure Bit Flags Name

Meaning

ICC_ANIMATE_CLASS ICC_BAR_CLASSES

Loads the animate control class. Loads the toolbar, status bar, trackbar, and tooltip control classes. Loads the rebar control class. Loads the date and time picker control class. Loads the hot key control class. Loads the IP address class. Loads the list view and header control classes. Loads the pager control class. Loads the progress bar control class. Loads the tab and tooltip control classes. Loads the tree view and tooltip control classes. Loads the up-down control class. Load the ComboBoxEx class. Loads the animate control, header, hot key, list view, progress bar, status bar, tab, tooltip, toolbar, trackbar, tree view, and up-down control classes.

ICC_COOL_CLASSES ICC_DATE_CLASSES ICC_HOTKEY_CLASS ICC_INTERNET_CLASSES ICC_LISTVIEW_CLASSES ICC_PAGESCROLLER_CLASS ICC_PROGRESS_CLASS ICC_TAB_CLASSES ICC_TREEVIEW_CLASSES ICC_UPDOWN_CLASS ICC_USEREX_CLASSES ICC_WIN95_CLASSES

Notifications for Windows Common Controls Windows common controls use a different messaging system than do standard Windows controls. This section takes a look at just what’s going on in the new messaging system and demonstrates how to tap into common control communications. Each of the Win32 common controls has a corresponding set of notification codes defined for its control type. In addition to these codes, there is a set of codes shared by all the common controls. These notifications all pass a pointer to an NMHDR structure (described in the following section), and are shown in Table Table Notification Codes Used by All the Win32 Common Controls 61 /

MFC Programming with Visual C++ 6 Unleashed

Summary

Notification Code

Meaning

NM_CLICK

Sent when a user clicks the left mouse button within the control. Sent when a user double-clicks the left mouse button within the control. Sent when the control loses the input focus. Sent when the control can’t finish an operation because of insufficient free memory. Sent when a user clicks the right mouse button within the control. Sent when a user double-clicks the right mouse button within the control. Sent when a user presses the Enter key and the control has the input focus. Sent when the control receives the input focus.

Hello,

Under very heavy load (at random different points in the application and at random time intervals from the start) my application crashes with the exception below.

Unfortunately the Generic error is not very helpful and I'm having major problems debugging it. Tracing the code with a debugger leads to where hibernate start executing the query.

One weird thing is that there is a single transaction active when I query postgresql about it, unfortunately there really is no way of telling what the query for the open transaction was, there certainly are no weird or long running queries in the log. The transaction can also be from the previous running query, but again debugging this is hell as it crashes randomly.

One strategy I'm persuing is to increase the per-thread/job limit (if it exists) of queries within Jboss5/Hibernate. I've played around with <property name="sprers.eu_size" value="20" /> but that does not solve it too. datasource settings are min/max 0/ Postgresql reports just 2 connections from hibernate, one of which is always idle.

I'm sorry for the lousy report, but that's all I have atm.

Dennis


Hibernate version:
Hibernate EntityManager GA
Hibernate Annotations GA
Hibernate
(All from Jboss 5 embedded beta 2)

Mapping documents:
None, all annotations

Code between sprers.eussion() and sprers.eu():
Varies

Full stack trace of any exception that occurs:

Quote:

ERROR 34, (sprers.eu) Exception while running:sprers.eutenceException: sprers.eucJDBCException: Cannot open connection
sprers.eunsactionRolledbackException: sprers.eutenceException: sprers.eucJDBCException: Cannot open connection
at sprers.euInCallerTx(sprers.eu)
at sprers.euInCallerTx(sprers.eu)
at sprers.eurceptor$sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eunvoke(sprers.eu)
at sprers.eunvoke(sprers.eu)
at sprers.eu(sprers.eu)
at $ProxygetLowestSecurityPriceExchangeArchive(Unknown Source)
at sprers.euketPrice(sprers.eu)
at sprers.eurentStatus(sprers.eu)
at sprers.eue(sprers.eu)
at sprers.eutedMethodAccessorinvoke(Unknown Source)
at sprers.eu(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euTarget(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eud(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.euInOurTx(sprers.eu)
at sprers.eurceptor$sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eunvoke(sprers.eu)
at sprers.eunvoke(sprers.eu)
at sprers.eu(sprers.eu)
at $Proxyexecute(Unknown Source)
at sprers.eu(sprers.eu)
at sprers.euingy(sprers.eu)
at sprers.eu0(Native Method)
at sprers.eu(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euMethod(sprers.eu)
at sprers.euTestMethod(sprers.eu)
at sprers.euTestMethods(sprers.eu)
at sprers.euTestMethods(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.eukers(sprers.eu)
at sprers.eueRun(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.eut(sprers.eu)
at sprers.euuentially(sprers.eu)
at sprers.eueRun(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euAndRunSuiteRunners(sprers.eu)
at sprers.eutesLocally(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.eu(sprers.eu)
Caused by: sprers.eutenceException: sprers.eucJDBCException: Cannot open connection
at sprers.euersistenceException(sprers.eu)
at sprers.euultList(sprers.eu)
at sprers.euestSecurityPriceExchangeArchive(sprers.eu)
at sprers.eutedMethodAccessorinvoke(Unknown Source)
at sprers.eu(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euTarget(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eud(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euNext(sprers.eu)
at sprers.euInCallerTx(sprers.eu)
73 more
Caused by: sprers.eucJDBCException: Cannot open connection
at sprers.eudNonSpecificException(sprers.eu)
at sprers.eut(sprers.eu)
at sprers.eut(sprers.eu)
at sprers.eut(sprers.eu)
at sprers.eunnection(sprers.eu)
at sprers.eunection(sprers.eu)
at sprers.eueQueryStatement(sprers.eu)
at sprers.eueQueryStatement(sprers.eu)
at sprers.euy(sprers.eu)
at sprers.euyAndInitializeNonLazyCollections(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.eunoreQueryCache(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.eumList(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.eu(sprers.eu)
at sprers.euultList(sprers.eu)
87 more
Caused by: sprers.euSQLException: Transaction is not active: tx=TransactionImple < ac, BasicAction: -3f57fdff:cdbdb8 status: sprers.eu_ONLY >; - nested throwable: (Transaction is not active: tx=TransactionImple < ac, BasicAction: -3f57fdff:cdbdb8 status: sprers.eu_ONLY >)
at sprers.eunection(sprers.eu)
at sprers.eunection(sprers.eu)
at sprers.eunnection(sprers.eu)
more
Caused by: Transaction is not active: tx=TransactionImple < ac, BasicAction: -3f57fdff:cdbdb8 status: sprers.eu_ONLY >
at sprers.euagedConnection(sprers.eu)
at sprers.euteConnection(sprers.eu)
at sprers.eunnectionManager2$sprers.euteConnection(sprers.eu)
at sprers.eunection(sprers.eu)
more



Name and version of the database you are using:
Postgresql , JDBC connector jdbc3

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Quote:

<Lots of queries before this, noting that the database cannot handle>

WARN [main] (sprers.eu:logExceptions) SQL Error: 0, SQLState: null
ERROR [main] (sprers.eu:logExceptions) Transaction is not active: tx=TransactionImple < ac, BasicAction: -3f57fdff:cdbdb8 status: sprers.eu_ONLY >; - nested throwable: (Transaction is not active: tx=TransactionImple < ac, BasicAction: -3f57fdff:cdbdb8 status: sprers.eu_ONLY >)
INFO [main] (sprers.eu:close) closing
INFO [main] (sprers.eu:removeInstance) Unbinding factory from JNDI name: sprers.eu:jar=sprers.eu,unitName=stocketeer
INFO [main] (sprers.eu:getInitialContext) JNDI InitialContext properties:{sprers.eul=sprers.euContextFactory, sprers.eu=sprers.eu:sprers.euaces}
INFO [main] (sprers.eu:removeInstance) Unbound factory from JNDI name: sprers.eu:jar=sprers.eu,unitName=stocketeer



Valid Accounts]] and information [[Collection]] that include keylogging and user input field interception. Learn more DiscoveryTSystem Time Discovery The system time is set and stored by the Windows Time Service within a domain to maintain time synchronization between systems and services in an enterprise network. Learn more TQuery Registry Adversaries may interact with the Windows Registry to gather information about the system, configuration, and installed software. Learn more TApplication Window Discovery Adversaries may attempt to get a listing of open application windows. Learn more Lateral MovementTRemote Desktop Protocol Remote desktop is a common feature in operating systems. Learn more CollectionTInput Capture
  • Collection
  • Credential Access
Adversaries can use methods of capturing user input for obtaining credentials for [[Technique/T

'Exception: DBD, ORA two-task conversion routine: integer overflow

May 21, , pm

: Latest and popular articles on SAP ERP

Next chasm traps query

Previous How to Sort a Measure Object

Dear Folks,

I have a report on Freehand Sql migrated from BO to BOXI R3 .This report works fine in BO and gives proper result.

The schemas on which Query is fired is on Database Oracle .The client used by BOXI3 server or User desk is Orcale 10g.

The query runs fine when fired from PLSQL Oracle 10 g and gives proper results.

Both, Infoview and DeskI is throwing error as 'Exception: DBD, ORA two-task conversion routine: integer overflow

Can you please help/suggest what requires to be done to get it resolved

Is there any settings which needs to be changed.

Thanks In advance


April 27, , pm

: Latest and popular articles on SAP ERP

Next Optional prompt giving error in universe

Previous 'Exception: DBD, ORA two-task conversion routine: integer overflow

hi every one, i'm new to bobj   and i'm getting problem and alot of confusion in chasm traps & fan traps . please tell me  in detail with an example. thank you.

January 28, , pm

: Latest and popular articles on SAP ERP

Next what is functional document in SAP BO and connections

Previous chasm traps query

Hi All,

I am trying to create optional prompt in Universe.  I am getting parsing error. Can any one plz correct this error.

Trunc(@Prompt('Enter state values','A','Store\State',multi,free,not_persistent,,' ',optional))

parsing error shows:

Parse failed: Invalid defination (UNV), Error parsing default values parameter (7th parameter).

Thanks,

Poorna

April 3, , am

: Latest and popular articles on SAP ERP

Next Error trying to modify SQL in Data Provider

Previous Optional prompt giving error in universe

Hi All,

Can you Plz give me the information about the   functional  document in SAP BO

and

Q) in sap Bo universe there is 3 type's of connections (personal,sheared,secured )is there  hear my Q's is

    my connection is sheared ,it's possible to universe export to cms and repository

Thanks,

Ramesh .P

January 15, , am

: Latest and popular articles on SAP ERP

Next BusinessObjects XI FP1 Report Conversion tool

Previous what is functional document in SAP BO and connections

I am attempting to modify the generated SQL in a DESKI report and save with the Do Not Generate box checked.

If I attempt to modify the generated SQL and check the Do Not Generate box when I click on OK or Verify SQL button I get the following error:

Exception: DBD, [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be sprers.eu:

Any ideas as to what could be the problem?

Thanks.

August 3, , pm

: Latest and popular articles on SAP ERP

Next ORA synonym translation is no longer valid

Previous Error trying to modify SQL in Data Provider

Hi:

We are trying to use the Report conversion tool in BusinessObjects XI FP1 and every time we do we get the error, Failed: Error on Web intelligence server.

RCT png

RCT #sprers.eu

Ant help on what we are doing wrong?

Brad

October 16, , am

: Latest and popular articles on SAP ERP

Next '*ALL' option in LOV of a prompt to select ALL values

Previous BusinessObjects XI FP1 Report Conversion tool

Hi,

We have newly upgraded to SAP BI and we have converted Deski report to webi report, the reports got fully converted but we still receive error  while running the report.   ORA Synonym translation is no longer valid .

Regards

Arun K

January 17, , am

: Latest and popular articles on SAP ERP

Next Desktop Intelligence Business Objects XI Release 2 Download ?

Previous ORA synonym translation is no longer valid

Hi Experts,

Please help on how to get '*ALL' option in LOV of a prompt to select ALL values in the LOV of the object at report level by editing the SQL of the report in DESKI XI R3.

In BO FC the below syntax was working but in XI R3 its not.

(sprers.eu IN @variable('1. Select Column:') or 'ALL' in @variable('1. Select Column:') )

Many Thanks.


November 30, , am

: Latest and popular articles on SAP ERP

Next CDaoException ERROR (Error ) when accessing txt file

Previous '*ALL' option in LOV of a prompt to select ALL values

Hello

I'm looking for the installfiles for Desktop Intelligence for Business Objects XI Release 2

Desktop Intelligence jpg

Business Objects Desktop Intelligence XI Release sprers.eu

I just have to open a few Deski Report in order to rebuild them in Webi. I only have to see the structure.

BO XI Clienttools have the Deski Client within but it is too new to open the really old files.

Do you have an idea how to get the install files as there is no availability on SAP marketplace or any other idea how to open the rep files?.

Thank you very much for your support.

Best regards

Michael Wecker

November 24, , am

: Latest and popular articles on SAP ERP

Next Infoview and VBA

Previous Desktop Intelligence Business Objects XI Release 2 Download ?

Hello,

I'm trying to import data from a text file in BO XIR2 and get the following error :

CDaoException SCODE_CODE = SCODE_FACILITY = 4 SCODE_SEVERITY = 1 ResultFromScode =

I've seen a another for an older version of BO suggesting to re-install microsoft data access but these software is already part of windows XP (it does not let me install any previous version).

All suggestion is welcome.

Thanks.

August 10, , am

: Latest and popular articles on SAP ERP

Next Unable to Schedule BO reports in Deski

Previous CDaoException ERROR (Error ) when accessing txt file

Hi to all,

I've tried to publish some reports to Infoview which have got a lot of VBA (these are legacy reports, done with ). They used to work perfectly through Infoview and BusinessObjects, but now they work only with DesktopIntelligence.

Is there a way to debug/see some logs from Infoview?

Thanks

Daniele

November 10, , am

: Latest and popular articles on SAP ERP

Next Issues on exporting the report to Excel from full client BO

Previous Infoview and VBA

I am unable to schedule reports in BO DeskI.  I see where we can schedule and send reports from Deski to WebI.  But, my users want to be able to schedule and retrieve reports from WITHIN Deski.  We use to have the capability to use TOOL, CONSOLE in the old version but this went away.  Can someone please instruct me on how to perform this function -- again in Deski only.

Thanks.

April 1, , am

: Latest and popular articles on SAP ERP

Next Scheduling BO XI report following ETL workflow

Previous Unable to Schedule BO reports in Deski

Hi,

I am facing a problem in exporting the BO report from Business Objects to excel file. I am aware that there is no direct way to export the BO report to Excel from Business Objects(File--> save as to .txt file and then copy its data to excel )

When the export the BO report to excel file,I received two errors one over other

error1: Numeric data overflow ()

When I click OK button, second error received is like this

error2:export failed (dma)

I tried all options to fix this and also I looked for an dialog box " export to external file format " in Business Objects inorder to copy the report data to COPY TO DDE option but I didn't find any aforementioned dialog box

Please provide me the solution to fix the issues

Kind Regards,

Srinivas

May 17, , pm

: Latest and popular articles on SAP ERP

Next Use today's date as criteria

Previous Issues on exporting the report to Excel from full client BO

Hi Team,

In my project, the scenario is like this -

One ETL(Informatica workflow) runs every monday(once in a week) and loads the data in the target database sprers.eu on this data, a BO(webi report/crystal/deski) report should run immediately and generate its output in desired format(say excel format) for end users

As per my understanding, I could run the BO report manually after the completion of ETL sprers.eu there a way to schedule a BO report(for example webi report) to run it automatically following ETL workflow. If yes then how to communicate BO server with Informatica server for automatic schedule

Appreciate your help

Kinds Regards,

Srini

June 21, , pm

: Latest and popular articles on SAP ERP

Next DESKI COMPATIBILITY PACK @variable('BOLANGUAGE')

Previous Scheduling BO XI report following ETL workflow

Hello,

I'm using Desktop Intellegence in BOE II R2.  I'm creating a report where I want to see everything where a date field is greater than today's date.  Is there a built in function that will do this?  I'm not able to find it anywhere.

Thank you!


July 6, , pm

: Latest and popular articles on SAP ERP

Next End of life and support for Desktop Intelligence

Previous Use today's date as criteria

Hello All,

I am having an issue whereby no data is displayed when a local environment is used in my query.

Example of where clause:

WHERE

   ( x = upper(@variable('BOLANGUAGE')) )

I am using the DCP feature in BI

Regards,

Tunwiir

May 3, , am

: Latest and popular articles on SAP ERP

Next Row level hidding in Deski report

Previous DESKI COMPATIBILITY PACK @variable('BOLANGUAGE')

Hi!

We are aware that SAP Business Objects is not going to invest in Desktop Intelligence for any enhancement what so ever. But, is it likely that Desktop Intelligence would be completely discarded? If this is the case when is it likely to happen? Is there a document that speaks of this?

There is this page which describes EOL for various BOBJ products but has no mention of

Deski: Product End of Life Dates: Current Products[original link is broken]

Kindly share your information and awareness.

Many thanks,

Rahul

October 28, , am

: Latest and popular articles on SAP ERP

Next #EMPTY value only in report filter but there's no EMPTY value in table!

Previous End of life and support for Desktop Intelligence

Hi

We are trying to hide rows based on condition in Deski report, 

Column 1      Column 2

     1X                 A

     1X                 B

     2X                 A

     3X                 B

OUTPUT in the report has to be like below.

Column 1      Column 2

     1X                 A

     2X                 A

     3X                 B

If we have two records for column1 for 1X,1X , it has to disply only one record in the report  A, the B value must be hidden.

Please give your valuable inputs and solutions

Thanks

Arun K

January 31, , am

: Latest and popular articles on SAP ERP

Next How can schedule a download excel report from business objects

Previous Row level hidding in Deski report

Hi all,

we create a simple report showing the list of months and the revenue. If we:

- create a filter in report conditions (when we build it)

- create a filter in Webi Rich Client

- create a filter in Infoview

we see the correct list of values (from Jan to Dec).

If we are in the report and apply filter directly on the month (by clicking on the month column and the funnel on the tool bar), we see the list (Jan   Dec) followed by #EMPTY value.

Months are 1 to n to fact table. Value is never null.

How can this happen? And why only in this situation?

Thank you for help.

May 22, , am

: Latest and popular articles on SAP ERP

Next Export Failed Error (DX)

Previous #EMPTY value only in report filter but there's no EMPTY value in table!

HI,  I am using BO

And I have a  report .wid that my client wants to be downloaded into excel 1 time a day.

Somebody can help me on this?

Thanks

Daniel


More Pages to Explore


WTL Developer's Guide

User Manual:

Open the PDF directly: View PDF PDF.
Page Count:

WTL Developer’s Guide By Eamon O’Tuathail (sprers.eu) This document is available under the Creative Commons’ Public Domain Dedication sprers.eu WTL Developer’s Guide Table Of Contents CHAPTER 1 OVERVIEW OF WTL OBJECTIVES OVERVIEW AIMS OF WTL RELATIONSHIP BETWEEN WTL, ATL AND WIN32/WIN64 API ALTERNATIVES TO WTL – ATL, MFC, VB, JAVA, DHTML OR … INSTALLATION OF WTL CONTENTS OF WTL’S INSTALLATION POSSIBLE PROBLEMS WITH THE INSTALLATION RESOURCES TARGET AUDIENCE FOR THIS DEVELOPER’S GUIDE CHAPTER CONTENTS CHAPTER 2 WIN32 SDK WINDOWING OBJECTIVES FUNDAMENTAL WINDOWING CONCEPTS MESSAGES THREADS AND WINDOWING CHAPTER 3 ATL WINDOWING OBJECTIVES OVERVIEW WINDOWING WITH ATL WINDOW CONSTRUCTION MESSAGE MAPS SUBCLASSING AND SUPERCLASSING CCONTAINEDWINDOW HIGHER-LEVEL UI DIALOG BOXES WINDOWING FOR ACTIVEX CONTROLS ACTIVEX CONTROL CONTAINMENT CHAPTER 4 WTL QUICK TOUR OBJECTIVES THE WTL DISTRIBUTION TEMPLATES AND CLASSES WHAT IS NOT IN WTL DEVELOPMENT ISSUES COMPLETE LIST OF MACROS USED IN WTL DEBUGGING WITH WTL DETAILED COMPARISON BETWEEN MFC AND WTL WTL’S CSTRING CHAPTER 5 THE WTL APPWIZARD OBJECTIVES JUST SAY “HELLOWORLD” MODAL DIALOG-BASED APPLICATION 2 WTL Developer’s Guide DEFAULT PROJECT SETTINGS SDI APPLICATION MDI APPLICATION MULTIPLE THREADS SDI MODELESS DIALOG-BASED APPLICATION APPLICATION FEATURES - ACTIVEX CONTROL HOSTING APPLICATION FEATURES - ACT AS A COM SERVER STEP 2 OF THE WTL APPWIZARD THREADS WITH COM AND WINDOWING CHAPTER 6 DIALOG BOXES AND CONTROLS OBJECTIVES INTRODUCTION DIALOG BOXES IN WTL DDX WTL WRAPPERS FOR THE STANDARD CONTROLS WTL WRAPPERS FOR COMMON CONTROLS CHAPTER 7 GRAPHICAL PRIMITIVES OBJECTIVES OVERVIEW GETTING STARTED WITH WTL GRAPHICS WTL HELPER CLASSES – CSIZE, CPOINT AND CRECT GDI OBJECTS AND HANDLE MANAGEMENT DEVICE CONTEXT TEMPLATES MANAGING ATTRIBUTES OBJECTS LINES AND PENS FILLED SHAPES AND BRUSHES TEXT AND FONTS CHAPTER 8 INTERNALS OF WTL OBJECTIVES OVERVIEW HEADER FILES CONTENTS OF EACH HEADER FILE 3 WTL Developer’s Guide Chapter 1 Overview of WTL Objectives The objectives of this chapter are to: • See where WTL fits into the “big picture” of VC++ development • Examine its aims • Contrast WTL with other UI development techniques • Explain the installation of WTL • Describe what is installed with WTL • List the available development resources • Describe the following chapters Overview In the past Visual C++ developers often choose MFC as it provided functionality in a very wide range of technologies, while the template libraries covered limited areas. More recently the range and quality of the template libraries have been improving and now the template answer is more and more often chosen. The design goal of ATL is to provide fast compact COM components. ISO C++’s STL provides collections. The VC++ OLE DB Data Consumer and Provider Templates provide database support. In contrast, MFC provides a single library of C++ classes, which provide a reasonable range of features in COM creation, collection classes, database classes and user interface. Most advanced developers prefer the newer template-route to development. MFC is monolithic, bulky, not very thread-friendly and, well, is basically old-fashioned! The template approach is fast (when designed correctly), flexible, covers all the latest techniques and for new development is definitely the way to go. Up to now the one major problem for template enthusiasts was how to create the graphical user interface. ATL does provide lightweight wrappers around Win32/64 windowing, but it certainly does not cover all UI needs. In the past, for anything other than trivial UI, ATL developers had to resort to MFC UI programming or developing a VB front-end to their ATL COM components, neither of which was totally satisfactory. Enter the Windows Template Library. The WTL is an advanced set of wrappers and productivity enhancement templates, which sit above the Win32/64 API, and provide 4 WTL Developer’s Guide comprehensive support for a wide variety of graphical user interface requirements. Keeping true to the template library tradition, WTL is small, ultra-fast and nonintrusive. It covers the latest UI concepts. It works well with multithreading. You can use WTL on its own or along with any combination of ATL, STL, VC++ Data Templates, third-party template libraries and your own custom templates libraries, incorporating just the features you need in each application. WTL usually has no dependencies on external DLLs – you only need to ship to end-users the EXE for the WTL application. Aims of WTL WTL is to the user interface what ATL is to COM or STL is to collections. Like its cousins, WTL takes a little while to learn, but when mastered there is no better way of developing the most advanced applications. Essentially, WTL accomplishes three significant tasks: • Providing an application framework • Aggregating UI functionality • Wrapping windowing controls, system dialogs and GDI objects Let’s examine each of these. Providing An Application Framework WTL provides a lightweight yet comprehensive application framework, which automatically furnishes applications based on it with many desirable facilities. The goal is something less than the impenetrable MFC framework, and something easier than starting to code WinMain manually. WTL comes in the form of a series of C++ templates and a WTL AppWizard. The AppWizard asks the application developer a few questions and then generates a VC++ project and application source code, much of which instantiates or derives from the WTL templates and classes. In general, what application developers might wish to change is in the AppWizard-generated application source code, and the “boiler-plate” style code, which rarely needs to be changed, is inside the WTL templates. Where necessary these templates may be derived from and custom functionality provided. WTL has a class to manage a module (a DLL or EXE). This class is instantiated in the AppWizard-generated application code and within the generated WinMain it is initialized and terminated. A WTL application can optionally act as a COM server, thus supporting programmable applications. WTL provides message-handling support and includes message filtering and on-idle functionality. Change notifications from WM_SETTINGCHANGE messages may be handled. MFC provides a document-frame-view architecture. WTL does provide frames (i.e. a top-level window, containing a menu bar, toolbar and statusbar) and views, but does not support documents at all. The MFC approach often got in the way of more advanced developers, and its documents were based on serialized binary data. In the modern Internet-world, document formats based on XML/XSL are becoming popular and there 5 WTL Developer’s Guide are demands for flexible storage mechanisms – it might not be the local hard disk; documents might need to be stored using a variety of remoting architectures, such as WebDAV or FTP. WTL provides no functionality regarding data formats or storage mechanisms. Application developers will have to write their own code for these tasks, e.g. using the fast Win32 APIs WriteFileGather / ReadFileScatter or an XML parser. WTL supports applications based on dialog-box, single document interface (SDI) or a multi-document interface (MDI). For SDI, it also supports multi-threaded SDI, with one thread per SDI window. It is expected that most advanced applications will use this architecture (e.g. following the Word approach). WTL does not support a multithreaded MDI architecture with one thread per MDI child window. This is sensible, as this avoids a variety of problems with the interaction between threads and MDI parentchild windows. Aggregating UI Functionality WTL provides a range of “must-have” features for applications requiring a modern user interface. A frame window is provided which manages a rebar control containing a command bar (enhanced menubar) and a toolbar, a status bar and one or more views. The views may be based on a generic empty window, or on controls such as richedit, listview or treeview. If more than one view is used, then the WTL splitter functionality can be employed to render multiple views with a moveable splitter divider. The views can also be scrolled. The status bar can be single-paned or multi-paned. WTL does support traditional menu bars and toolbars, but its main menu presentation concept is based around command bars. A command bar contains menus and toolbar icons, and can be displayed and moved around within a rebar control. If a menu item has the same command id as a toolbar icon, then when the menu is rendered the equivalent icon is rendered next to each item. WTL supports neither docking nor floating command bars. WTL’s command-bars are similar to those in Internet Explorer, and not like the (much more desirable!) command-bars in Word or Visual Studio. WTL does not support shortened menus based on usage-data (e.g. WORD). The concept of dynamic data exchange allows the transfer in both directions of values between on-screen user interface controls and C++ data members. This functions quite similarly to MFC’s DDX. Dialog boxes may be created using ATL, including those, which support ActiveX, control containment. Visual C++’s ResourceView can be used to layout standard controls, common controls and ActiveX controls in the dialog resource template. The ATL Window Message Handler Wizard can be used to map incoming messages for these controls to message handlers. WTL provides templates to manage property sheets and property page construction and wizard construction. Printing is supported through a printer device context, print preview, devmode handling and print job management functionality. 6 WTL Developer’s Guide Enhanced metafiles are supported using a special device context, file management and enhanced metafile information classes. Wrapping Windowing Controls, System Dialogs and GDI objects ATL provides access to generic window functionality, but provides no special support for windows based on different windows classes. Developers had to resort to manually coding SendMessage calls as needed. So whether communicating with an edit or a treeview control, they had to use ATL’s CWindow and call Win32’s SendMessage with EM_LIMITTEXT or VM_SETITEM and ensure that the parameters were correct for each message (no type checking was performed). When applications received them they were in the raw format – wParam and lParam as sent on the message queue. Applications needed code to convert these to appropriate data types; again making sure the correct conversion was made for each message type. Some ATL developers were using code extracted from the ATLCON sample, which provide some wrappers for Windows UI elements. This has evolved into a full set of comprehensive wrappers for all the standard and common window controls, the system dialogs and all the GDI objects, and much more. There are WTL classes for edit, button, listbox, treeview, listview etc. There are wrappers for the common file dialog, the color dialog, the font selection dialog, etc. There are wrappers for the device context, pen, brush, region, font etc. In addition, a full set of message crackers is provided. Incoming messages are mapped to message handlers. With ATL these message handlers were passed lParam and wParam. With WTL’s message crackers, the message handlers’ input is specific to the incoming message. For example, the handler for WM_LBUTTONDOWN is passed in a CPoint parameter (CPoint is a WTL wrapper for the Win32 POINT structure – WTL also has wrappers for such common structures). Note that the ATL Windows Message Handler Wizard uses ATL’s raw message maps, not WTL’s message crackers. It is likely wizard support will be improved in the next version of Visual C++. Many developers choose to use MFC solely for its string-handling support. WTL eliminates this need by providing its own implementation of CString, which is a comprehensive clone of MFC’s CString. The string formats WTL’s CString supports include ASCII, MBCS, UNICODE and Automation’s BSTR. It supports conversions between all these formats. It supports string manipulation such as concatenation, trimming and comparison. Its supports printf-like string formatting. It supports flexible memory management. Relationship Between WTL, ATL and Win32/Win64 API WTL is based on ATL and Win32/Win64, and ATL is based on Win32/Win When considering their relationships, we need to examine the source code view and the binary deliverable view. Source Code The Win32/Win64 API is a set of thousands of C functions, covering a vast range of topics – including two that interest us here, COM and windowing. 7 WTL Developer’s Guide ATL is a set of C++ templates, which mostly are dedicated to COM programming, but also include comprehensive low-level support for windowing functionality. Your Application Code WTL-AppWizard generated code WTL ATL Win32/Win64 API WTL is a set of C++ templates, which focus purely on higher-level windowing functionality. WTL is independent of COM, but can be use along with COM in an application. Provided you do not select the “Com Server” support in the WTL AppWizard, then CoInitialize is not actually called. WTL uses the ATL windowing services, so therefore to use WTL you must have access to the ATL templates. ATL makes calls to the Win32/Win64 API. WTL makes calls to the ATL templates and the Win32/Win64 API. Your application code makes calls to WTL, ATL and the Win32/Win64 API. When you run the WTL AppWizard, it produces a number of source files, which become part of your application source code. The generated source files make calls into WTL and sets up the framework for the application. WTL supports Windows , Windows Me, Windows NT 4, Windows 98, Windows 95 OSR 2 and “Classic” Windows WTL support of these is not of the “lowest common denominator” variety. Instead it uses some #defines (e.g. _RICHEDIT_VER, _WIN32_IE, _WIN32_WINNT and WINVER) to determine which Win32/Win64 features to use. WTL does not auto-detect the installed versions of the OS or Internet Explorer (e.g. it does not use the LoadLibrary / GetProceAddress or GetVersionEx APIs). Instead, the application developer must specify the #defines, and the application during compilation will assume they are available on the client machine and will not run if absent. As an example of this, take chevrons in menus. When a command-bar is shortened due to a window resize and chevrons are not used, then the piece of the command-bars, which are outside the windows boundaries, are unceremoniously cut off. These two 8 WTL Developer’s Guide screen dumps are an example of a WTL application with a window in full size and reduced – you note the help menu title and the paste toolbar icon are chopped in half. The chevron is a symbol comprising two greater-than signs. When pressed, it displays a pop-down menu containing the items, which have been chopped off the end of the command-bar and toolbar due to resizing. Chevrons are supported if Internet Explorer 5 is included, and are not supported otherwise. In a WTL application, if _WIN32_IE is set to 0x or later (e.g. in stdafx.h) then the chevron is displayed when needed. These two screen dumps show a WTL application with a resized window, with the chevron not pressed and pressed. Note that if Internet Explorer 5 or later is installed, but _WIN32_IE is not set as 0x or later, then chevrons are not supported in the application, even though the installed OS does support them. WTL does not support PocketPC or X-Box, though it would be nice to see this in future and there are no technical reasons preventing it. It does seem that WTL is prepared for Win64, as consideration for bit programming is obvious from some of the WTL source files. Binary Deliverable ATL and WTL are delivered as a set of header files containing C++ templates. ATL does also have a small number of C++ classes – and these may be used as a separate DLL but the vast majority of application developers also include them in each project, and with WTL applications this is also recommended. WTL does not have separate DLL option. So as needed, the WTL C++ classes (there are a few of them) will be included in each application. When you compile a WTL application you will end up with an EXE or a DLL. That is all you have to deliver to the end-user of the application. There are no dependencies on 9 WTL Developer’s Guide external libraries, apart from OS libraries such as KernelDLL, which are always present (if not, then Windows itself would have problems starting). One exception to this “no-dependencies” rule is if you need to use floating-point numbers. If this is the case, then you will need to ship the C-Runtime Library (CRT). Alternatives to WTL – ATL, MFC, VB, Java, DHTML or … As an application developer, you will certainly find plenty of options available when you need to construct a graphical user interface. No matter which you choose, you will often get other developers saying “why did you not use

I have written a program that adds data to a database which was
created with Access. My problem is that it can't open the database on
computers where Access has not been installed. This is complicated by
the fact that CDaoException's m_pErrorInfo is NULL after the failure,
so I'm having trouble figuring out what is wrong.

The code snippet below generates a message box with the following:
 ERROR:CDaoException
 SCODE_CODE =
 SCODE_FACILITY = 4
 SCODE_SEVERITY = 1
 m_nAfxDaoError =
 ResultFromScode =

I'm using Visual Studio 97 with service pack 3.

Everything works fine on systems where Access has been installed. I
notice that the system I'm working on has Data Access Objects (DAO)
installed, and the test system that isn't working does not. I'm
not sure whether DAO got installed along with Visual Studio,
Access, or what, but test have gone fine on several systems that don't
have Visual Studio.

I'd appreciate any suggestions.

 //open database
 pDB = new CDaoDatabase();
 try
 {
        pDB->Open(gsDBPath);
 }
 catch (CDaoException* e)
 {
        if (e->m_pErrorInfo == NULL)
        {
                CString str;
                sprers.eu(
                _T("ERROR:CDaoException\n\n")
                _T("SCODE_CODE             =%d\n")
                _T("SCODE_FACILITY =%d\n")
                _T("SCODE_SEVERITY =%d\n")
                _T("m_nAfxDaoError =%d\n")
                _T("ResultFromScode        =%d\n"),
                SCODE_CODE              (e->m_scode),
                SCODE_FACILITY  (e->m_scode),
                SCODE_SEVERITY  (e->m_scode),
                e->m_nAfxDaoError,
                ResultFromScode (e->m_scode));
                AfxMessageBox(str);
        }
        else
        {
                AfxMessageBox( "Generated CDaoException - invoking WinHelp" );
                WinHelp(GetDesktopWindow(),
                                e->m_pErrorInfo->m_strHelpFile,
                                HELP_CONTEXT,
                                e->m_pErrorInfo->m_lHelpContext);
        }
        delete pDB;
        pDB = NULL;
        e->Delete();
 }



Cdaoexception error code = 340 - intolerable

WTL Developer's Guide

User Manual:

Open the PDF directly: View PDF PDF.
Page Count:

WTL Developer’s Guide By Eamon O’Tuathail (sprers.eu) This document is available under the Creative Commons’ Public Domain Dedication sprers.eu WTL Developer’s Guide Table Of Contents CHAPTER 1 OVERVIEW OF WTL OBJECTIVES OVERVIEW AIMS OF WTL RELATIONSHIP BETWEEN WTL, ATL AND WIN32/WIN64 API ALTERNATIVES TO WTL – ATL, MFC, VB, JAVA, DHTML OR … INSTALLATION OF WTL CONTENTS OF WTL’S INSTALLATION POSSIBLE PROBLEMS WITH THE INSTALLATION RESOURCES TARGET AUDIENCE FOR THIS DEVELOPER’S GUIDE CHAPTER CONTENTS CHAPTER 2 WIN32 SDK WINDOWING OBJECTIVES FUNDAMENTAL WINDOWING CONCEPTS MESSAGES THREADS AND WINDOWING CHAPTER 3 ATL WINDOWING OBJECTIVES OVERVIEW WINDOWING WITH ATL WINDOW CONSTRUCTION MESSAGE MAPS SUBCLASSING AND SUPERCLASSING CCONTAINEDWINDOW HIGHER-LEVEL UI DIALOG BOXES WINDOWING FOR ACTIVEX CONTROLS ACTIVEX CONTROL CONTAINMENT CHAPTER 4 WTL QUICK TOUR OBJECTIVES THE WTL DISTRIBUTION TEMPLATES AND CLASSES WHAT IS NOT IN WTL DEVELOPMENT ISSUES COMPLETE LIST OF MACROS USED IN WTL DEBUGGING WITH WTL DETAILED COMPARISON BETWEEN MFC AND WTL WTL’S CSTRING CHAPTER 5 THE WTL APPWIZARD OBJECTIVES JUST SAY “HELLOWORLD” MODAL DIALOG-BASED APPLICATION 2 WTL Developer’s Guide DEFAULT PROJECT SETTINGS SDI APPLICATION MDI APPLICATION MULTIPLE THREADS SDI MODELESS DIALOG-BASED APPLICATION APPLICATION FEATURES - ACTIVEX CONTROL HOSTING APPLICATION FEATURES - ACT AS A COM SERVER STEP 2 OF THE WTL APPWIZARD THREADS WITH COM AND WINDOWING CHAPTER 6 DIALOG BOXES AND CONTROLS OBJECTIVES INTRODUCTION DIALOG BOXES IN WTL DDX WTL WRAPPERS FOR THE STANDARD CONTROLS WTL WRAPPERS FOR COMMON CONTROLS CHAPTER 7 GRAPHICAL PRIMITIVES OBJECTIVES OVERVIEW GETTING STARTED WITH WTL GRAPHICS WTL HELPER CLASSES – CSIZE, CPOINT AND CRECT GDI OBJECTS AND HANDLE MANAGEMENT DEVICE CONTEXT TEMPLATES MANAGING ATTRIBUTES OBJECTS LINES AND PENS FILLED SHAPES AND BRUSHES TEXT AND FONTS CHAPTER 8 INTERNALS OF WTL OBJECTIVES OVERVIEW HEADER FILES CONTENTS OF EACH HEADER FILE 3 WTL Developer’s Guide Chapter 1 Overview of WTL Objectives The objectives of this chapter are to: • See where WTL fits into the “big picture” of VC++ development • Examine its aims • Contrast WTL with other UI development techniques • Explain the installation of WTL • Describe what is installed with WTL • List the available development resources • Describe the following chapters Overview In the past Visual C++ developers often choose MFC as it provided functionality in a very wide range of technologies, while the template libraries covered limited areas. More recently the range and quality of the template libraries have been improving and now the template answer is more and more often chosen. The design goal of ATL is to provide fast compact COM components. ISO C++’s STL provides collections. The VC++ OLE DB Data Consumer and Provider Templates provide database support. In contrast, MFC provides a single library of C++ classes, which provide a reasonable range of features in COM creation, collection classes, database classes and user interface. Most advanced developers prefer the newer template-route to development. MFC is monolithic, bulky, not very thread-friendly and, well, is basically old-fashioned! The template approach is fast (when designed correctly), flexible, covers all the latest techniques and for new development is definitely the way to go. Up to now the one major problem for template enthusiasts was how to create the graphical user interface. ATL does provide lightweight wrappers around Win32/64 windowing, but it certainly does not cover all UI needs. In the past, for anything other than trivial UI, ATL developers had to resort to MFC UI programming or developing a VB front-end to their ATL COM components, neither of which was totally satisfactory. Enter the Windows Template Library. The WTL is an advanced set of wrappers and productivity enhancement templates, which sit above the Win32/64 API, and provide 4 WTL Developer’s Guide comprehensive support for a wide variety of graphical user interface requirements. Keeping true to the template library tradition, WTL is small, ultra-fast and nonintrusive. It covers the latest UI concepts. It works well with multithreading. You can use WTL on its own or along with any combination of ATL, STL, VC++ Data Templates, third-party template libraries and your own custom templates libraries, incorporating just the features you need in each application. WTL usually has no dependencies on external DLLs – you only need to ship to end-users the EXE for the WTL application. Aims of WTL WTL is to the user interface what ATL is to COM or STL is to collections. Like its cousins, WTL takes a little while to learn, but when mastered there is no better way of developing the most advanced applications. Essentially, WTL accomplishes three significant tasks: • Providing an application framework • Aggregating UI functionality • Wrapping windowing controls, system dialogs and GDI objects Let’s examine each of these. Providing An Application Framework WTL provides a lightweight yet comprehensive application framework, which automatically furnishes applications based on it with many desirable facilities. The goal is something less than the impenetrable MFC framework, and something easier than starting to code WinMain manually. WTL comes in the form of a series of C++ templates and a WTL AppWizard. The AppWizard asks the application developer a few questions and then generates a VC++ project and application source code, much of which instantiates or derives from the WTL templates and classes. In general, what application developers might wish to change is in the AppWizard-generated application source code, and the “boiler-plate” style code, which rarely needs to be changed, is inside the WTL templates. Where necessary these templates may be derived from and custom functionality provided. WTL has a class to manage a module (a DLL or EXE). This class is instantiated in the AppWizard-generated application code and within the generated WinMain it is initialized and terminated. A WTL application can optionally act as a COM server, thus supporting programmable applications. WTL provides message-handling support and includes message filtering and on-idle functionality. Change notifications from WM_SETTINGCHANGE messages may be handled. MFC provides a document-frame-view architecture. WTL does provide frames (i.e. a top-level window, containing a menu bar, toolbar and statusbar) and views, but does not support documents at all. The MFC approach often got in the way of more advanced developers, and its documents were based on serialized binary data. In the modern Internet-world, document formats based on XML/XSL are becoming popular and there 5 WTL Developer’s Guide are demands for flexible storage mechanisms – it might not be the local hard disk; documents might need to be stored using a variety of remoting architectures, such as WebDAV or FTP. WTL provides no functionality regarding data formats or storage mechanisms. Application developers will have to write their own code for these tasks, e.g. using the fast Win32 APIs WriteFileGather / ReadFileScatter or an XML parser. WTL supports applications based on dialog-box, single document interface (SDI) or a multi-document interface (MDI). For SDI, it also supports multi-threaded SDI, with one thread per SDI window. It is expected that most advanced applications will use this architecture (e.g. following the Word approach). WTL does not support a multithreaded MDI architecture with one thread per MDI child window. This is sensible, as this avoids a variety of problems with the interaction between threads and MDI parentchild windows. Aggregating UI Functionality WTL provides a range of “must-have” features for applications requiring a modern user interface. A frame window is provided which manages a rebar control containing a command bar (enhanced menubar) and a toolbar, a status bar and one or more views. The views may be based on a generic empty window, or on controls such as richedit, listview or treeview. If more than one view is used, then the WTL splitter functionality can be employed to render multiple views with a moveable splitter divider. The views can also be scrolled. The status bar can be single-paned or multi-paned. WTL does support traditional menu bars and toolbars, but its main menu presentation concept is based around command bars. A command bar contains menus and toolbar icons, and can be displayed and moved around within a rebar control. If a menu item has the same command id as a toolbar icon, then when the menu is rendered the equivalent icon is rendered next to each item. WTL supports neither docking nor floating command bars. WTL’s command-bars are similar to those in Internet Explorer, and not like the (much more desirable!) command-bars in Word or Visual Studio. WTL does not support shortened menus based on usage-data (e.g. WORD). The concept of dynamic data exchange allows the transfer in both directions of values between on-screen user interface controls and C++ data members. This functions quite similarly to MFC’s DDX. Dialog boxes may be created using ATL, including those, which support ActiveX, control containment. Visual C++’s ResourceView can be used to layout standard controls, common controls and ActiveX controls in the dialog resource template. The ATL Window Message Handler Wizard can be used to map incoming messages for these controls to message handlers. WTL provides templates to manage property sheets and property page construction and wizard construction. Printing is supported through a printer device context, print preview, devmode handling and print job management functionality. 6 WTL Developer’s Guide Enhanced metafiles are supported using a special device context, file management and enhanced metafile information classes. Wrapping Windowing Controls, System Dialogs and GDI objects ATL provides access to generic window functionality, but provides no special support for windows based on different windows classes. Developers had to resort to manually coding SendMessage calls as needed. So whether communicating with an edit or a treeview control, they had to use ATL’s CWindow and call Win32’s SendMessage with EM_LIMITTEXT or VM_SETITEM and ensure that the parameters were correct for each message (no type checking was performed). When applications received them they were in the raw format – wParam and lParam as sent on the message queue. Applications needed code to convert these to appropriate data types; again making sure the correct conversion was made for each message type. Some ATL developers were using code extracted from the ATLCON sample, which provide some wrappers for Windows UI elements. This has evolved into a full set of comprehensive wrappers for all the standard and common window controls, the system dialogs and all the GDI objects, and much more. There are WTL classes for edit, button, listbox, treeview, listview etc. There are wrappers for the common file dialog, the color dialog, the font selection dialog, etc. There are wrappers for the device context, pen, brush, region, font etc. In addition, a full set of message crackers is provided. Incoming messages are mapped to message handlers. With ATL these message handlers were passed lParam and wParam. With WTL’s message crackers, the message handlers’ input is specific to the incoming message. For example, the handler for WM_LBUTTONDOWN is passed in a CPoint parameter (CPoint is a WTL wrapper for the Win32 POINT structure – WTL also has wrappers for such common structures). Note that the ATL Windows Message Handler Wizard uses ATL’s raw message maps, not WTL’s message crackers. It is likely wizard support will be improved in the next version of Visual C++. Many developers choose to use MFC solely for its string-handling support. WTL eliminates this need by providing its own implementation of CString, which is a comprehensive clone of MFC’s CString. The string formats WTL’s CString supports include ASCII, MBCS, UNICODE and Automation’s BSTR. It supports conversions between all these formats. It supports string manipulation such as concatenation, trimming and comparison. Its supports printf-like string formatting. It supports flexible memory management. Relationship Between WTL, ATL and Win32/Win64 API WTL is based on ATL and Win32/Win64, and ATL is based on Win32/Win When considering their relationships, we need to examine the source code view and the binary deliverable view. Source Code The Win32/Win64 API is a set of thousands of C functions, covering a vast range of topics – including two that interest us here, COM and windowing. 7 WTL Developer’s Guide ATL is a set of C++ templates, which mostly are dedicated to COM programming, but also include comprehensive low-level support for windowing functionality. Your Application Code WTL-AppWizard generated code WTL ATL Win32/Win64 API WTL is a set of C++ templates, which focus purely on higher-level windowing functionality. WTL is independent of COM, but can be use along with COM in an application. Provided you do not select the “Com Server” support in the WTL AppWizard, then CoInitialize is not actually called. WTL uses the ATL windowing services, so therefore to use WTL you must have access to the ATL templates. ATL makes calls to the Win32/Win64 API. WTL makes calls to the ATL templates and the Win32/Win64 API. Your application code makes calls to WTL, ATL and the Win32/Win64 API. When you run the WTL AppWizard, it produces a number of source files, which become part of your application source code. The generated source files make calls into WTL and sets up the framework for the application. WTL supports Windows , Windows Me, Windows NT 4, Windows 98, Windows 95 OSR 2 and “Classic” Windows WTL support of these is not of the “lowest common denominator” variety. Instead it uses some #defines (e.g. _RICHEDIT_VER, _WIN32_IE, _WIN32_WINNT and WINVER) to determine which Win32/Win64 features to use. WTL does not auto-detect the installed versions of the OS or Internet Explorer (e.g. it does not use the LoadLibrary / GetProceAddress or GetVersionEx APIs). Instead, the application developer must specify the #defines, and the application during compilation will assume they are available on the client machine and will not run if absent. As an example of this, take chevrons in menus. When a command-bar is shortened due to a window resize and chevrons are not used, then the piece of the command-bars, which are outside the windows boundaries, are unceremoniously cut off. These two 8 WTL Developer’s Guide screen dumps are an example of a WTL application with a window in full size and reduced – you note the help menu title and the paste toolbar icon are chopped in half. The chevron is a symbol comprising two greater-than signs. When pressed, it displays a pop-down menu containing the items, which have been chopped off the end of the command-bar and toolbar due to resizing. Chevrons are supported if Internet Explorer 5 is included, and are not supported otherwise. In a WTL application, if _WIN32_IE is set to 0x or later (e.g. in stdafx.h) then the chevron is displayed when needed. These two screen dumps show a WTL application with a resized window, with the chevron not pressed and pressed. Note that if Internet Explorer 5 or later is installed, but _WIN32_IE is not set as 0x or later, then chevrons are not supported in the application, even though the installed OS does support them. WTL does not support PocketPC or X-Box, though it would be nice to see this in future and there are no technical reasons preventing it. It does seem that WTL is prepared for Win64, as consideration for bit programming is obvious from some of the WTL source files. Binary Deliverable ATL and WTL are delivered as a set of header files containing C++ templates. ATL does also have a small number of C++ classes – and these may be used as a separate DLL but the vast majority of application developers also include them in each project, and with WTL applications this is also recommended. WTL does not have separate DLL option. So as needed, the WTL C++ classes (there are a few of them) will be included in each application. When you compile a WTL application you will end up with an EXE or a DLL. That is all you have to deliver to the end-user of the application. There are no dependencies on 9 WTL Developer’s Guide external libraries, apart from OS libraries such as KernelDLL, which are always present (if not, then Windows itself would have problems starting). One exception to this “no-dependencies” rule is if you need to use floating-point numbers. If this is the case, then you will need to ship the C-Runtime Library (CRT). Alternatives to WTL – ATL, MFC, VB, Java, DHTML or … As an application developer, you will certainly find plenty of options available when you need to construct a graphical user interface. No matter which you choose, you will often get other developers saying “why did you not use
Valid Accounts]] and information [[Collection]] that include keylogging and user input field interception. Learn more