|
Hi,
you should use a DC(attach it to your print dialog printer DC), Start a document->start a page-> do whatever you want with the DC(whatever you do will be printed!)->end your page->end your document
look below:
CPrintDialog PDlg(FALSE);<br />
CDC PDC;<br />
<br />
<br />
<br />
PDC.Attach(PDlg.GetPrinterDC());<br />
<br />
PDC.StartDoc("New Name, will apear in systray");<br />
PDC.StartPage();<br />
<br />
PDC.TextOut(0,0,"HELLO!");<br />
<br />
PDC.EndPage();<br />
PDC.EndDoc();
|
|
|
|
|
I am using VC6 w/ MFC and have an app with the COleDocument/CView architecture. A COleClientItem is added (and activated) successfully to the document but now I would like to get at some of the resource items in that control, namely the icons. I figured I would use the ::LoadIcon and use the instance handle of the control but I don't know how to get it. The GetIconFromRegistry() is not useful as the control does not register its icon that way. (I wrote the OCX control and if someone knows how to register the icon, that would be fine as well.)
If I go the ::LoadIcon() route, how do I get the instance handle of the control?
Thanks!
|
|
|
|
|
Hi all,
I have been programming all my projects using C++ and MFC for the last 8 years. Now I think it's time for me to learn new things by using .NET when creating new features ( new dialogs, new code) on top of old projects.
Is it possbile for MFC DLL or MFC EXE to call a DLL that was created using .NET languages?
If the answer is yes, what is the best way to share ( pass) data structures between MFC EXE and .NET DLL?
Recommend any good book?
Thanks
|
|
|
|
|
VC++ 7.1 and VC++ 2005 both support the /clr mode, where your entire native code (MFC, ATL whatever) gets compiled into IL (exceptions to this rule exist). Now you can use .NET classes from your (previously)native apps just as if you were using native classes.
|
|
|
|
|
|
Hello I have some problem about Platform SDK using, I need help, but please read carefuly to know the problem and the situation first, Thanks!!!
Problem:
========
Windows Data Types: for examples:
ULONG_PTR
PDWORD_PTR
are undeclared identifier in MFC/VC++/Platform SDK!!!
Installation' situation:
========================
I have intalled the Platform SDK on my computer. The SDK install file was downloaded from MicoSoft website ( Windows® Server 2003 SP1 Platform SDK Web Install ).
The setup file name is:
PSDK-x86.exe.
The address is :
http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3- A93E-40C0EC4F68E5&displaylang=en
Platform SDK files situation:
=============================
After installed, on my computer, under the folder C:\Program Files\Microsoft Platform SDK\Include, I got the file BaseTsd.h, but in the file, there are no these Data types declarations!!!
Ms Platform SDK documentation Say:
==================================
All these Windows Data Types are declared in BaseTsd.h
So, some body can fig out the problem? Thanks
So, some body can fig out the problem? Thanks
So, some body can fig out the problem? Thanks
|
|
|
|
|
rat.crown wrote:
After installed, on my computer, under the folder C:\Program Files\Microsoft Platform SDK\Include, I got the file BaseTsd.h, but in the file, there are no these Data types declarations!!!
So what do you have in the BaseTsd.h file? What size is the file? Is this SDK for Visual Studio 6 or .Net?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
=====================
BaseTsd.h File Size:
=====================
Name Size Modified
BaseTsd.h 9 KB 4/14/2005
==============================================================
Windows® Server 2003 SP1 Platform SDK Web Install Description:
==============================================================
[Overview]
The Microsoft® Windows® Software Development Kit (SDK) provides the documentation, samples, header files, libraries, and tools you need to develop applications that run on Windows. The applications you develop with this edition of the SDK can run on the x86, x64 and Itanium-based versions of Windows Server 2003 SP1, Windows XP SP2, Windows XP x64 Pro Edition, and Windows 2000. A new custom install allows you to select components you wish to install on a more granular level.
[System Requirements]
Supported Operating Systems: Windows 2000; Windows Server 2003; Windows XP 64-bit; Windows XP Professional Edition ; Windows XP Service Pack 1
Development Tools. To build the C/C++ samples, you must have a C/C++ compiler. If you are using Microsoft Visual C/C++®, run it at least once before installing the SDK. This will ensure that the environment variables are correctly configured. To build the Visual Basic samples, you must have Microsoft Visual Basic®. This SDK does not support working with Microsoft Visual C/C++®, 6.0 as support for VC 6.0 has ended. The last SDK that will work with VC 6.0 is the February 2003 Edition, you can order a CD on the fulfillment site. Side by side installations are not supported.
========================
BaseTsd.h File content:
========================
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
basetsd.h
Abstract:
Type definitions for the basic sized types.
Author:
Revision History:
--*/
#ifndef _BASETSD_H_
#define _BASETSD_H_
#if !defined(_MAC) && (defined(_M_MRX000) || defined(_M_AMD64) || defined(_M_IA64)) && (_MSC_VER >= 1100) && !(defined(MIDL_PASS) || defined(RC_INVOKED))
#define POINTER_64 __ptr64
typedef unsigned __int64 POINTER_64_INT;
#if defined(_WIN64)
#define POINTER_32 __ptr32
#else
#define POINTER_32
#endif
#else
#if defined(_MAC) && defined(_MAC_INT_64)
#define POINTER_64 __ptr64
typedef unsigned __int64 POINTER_64_INT;
#else
#if (_MSC_VER >= 1300) && !(defined(MIDL_PASS) || defined(RC_INVOKED))
#define POINTER_64 __ptr64
#else
#define POINTER_64
#endif
typedef unsigned long POINTER_64_INT;
#endif
#define POINTER_32
#endif
#if defined(_IA64_) || defined(_AMD64_)
#define FIRMWARE_PTR
#else
#define FIRMWARE_PTR POINTER_32
#endif
#if _MSC_VER > 1000
#pragma once
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef signed char INT8, *PINT8;
typedef signed short INT16, *PINT16;
typedef signed int INT32, *PINT32;
typedef signed __int64 INT64, *PINT64;
typedef unsigned char UINT8, *PUINT8;
typedef unsigned short UINT16, *PUINT16;
typedef unsigned int UINT32, *PUINT32;
typedef unsigned __int64 UINT64, *PUINT64;
//
// The following types are guaranteed to be signed and 32 bits wide.
//
typedef signed int LONG32, *PLONG32;
//
// The following types are guaranteed to be unsigned and 32 bits wide.
//
typedef unsigned int ULONG32, *PULONG32;
typedef unsigned int DWORD32, *PDWORD32;
#if !defined(_W64)
#if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
#define _W64 __w64
#else
#define _W64
#endif
#endif
//
// The INT_PTR is guaranteed to be the same size as a pointer. Its
// size with change with pointer size (32/64). It should be used
// anywhere that a pointer is cast to an integer type. UINT_PTR is
// the unsigned variation.
//
// __int3264 is intrinsic to 64b MIDL but not to old MIDL or to C compiler.
//
#if ( 501 < __midl )
typedef [public] __int3264 INT_PTR, *PINT_PTR;
typedef [public] unsigned __int3264 UINT_PTR, *PUINT_PTR;
typedef [public] __int3264 LONG_PTR, *PLONG_PTR;
typedef [public] unsigned __int3264 ULONG_PTR, *PULONG_PTR;
#else // midl64
// old midl and C++ compiler
#if defined(_WIN64)
typedef __int64 INT_PTR, *PINT_PTR;
typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
typedef __int64 LONG_PTR, *PLONG_PTR;
typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
#define __int3264 __int64
#else
typedef _W64 int INT_PTR, *PINT_PTR;
typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;
typedef _W64 long LONG_PTR, *PLONG_PTR;
typedef _W64 unsigned long ULONG_PTR, *PULONG_PTR;
#define __int3264 __int32
#endif
#endif // midl64
//
// HALF_PTR is half the size of a pointer it intended for use with
// within structures which contain a pointer and two small fields.
// UHALF_PTR is the unsigned variation.
//
#ifdef _WIN64
#define ADDRESS_TAG_BIT 0x40000000000UI64
typedef __int64 SHANDLE_PTR;
typedef unsigned __int64 HANDLE_PTR;
typedef unsigned int UHALF_PTR, *PUHALF_PTR;
typedef int HALF_PTR, *PHALF_PTR;
#if !defined(__midl)
__inline
unsigned long
HandleToULong(
const void *h
)
{
return((unsigned long) (ULONG_PTR) h );
}
__inline
long
HandleToLong(
const void *h
)
{
return((long) (LONG_PTR) h );
}
__inline
void *
ULongToHandle(
const unsigned long h
)
{
return((void *) (UINT_PTR) h );
}
__inline
void *
LongToHandle(
const long h
)
{
return((void *) (INT_PTR) h );
}
__inline
unsigned long
PtrToUlong(
const void *p
)
{
return((unsigned long) (ULONG_PTR) p );
}
__inline
unsigned int
PtrToUint(
const void *p
)
{
return((unsigned int) (UINT_PTR) p );
}
__inline
unsigned short
PtrToUshort(
const void *p
)
{
return((unsigned short) (unsigned long) (ULONG_PTR) p );
}
__inline
long
PtrToLong(
const void *p
)
{
return((long) (LONG_PTR) p );
}
__inline
int
PtrToInt(
const void *p
)
{
return((int) (INT_PTR) p );
}
__inline
short
PtrToShort(
const void *p
)
{
return((short) (long) (LONG_PTR) p );
}
__inline
void *
IntToPtr(
const int i
)
// Caution: IntToPtr() sign-extends the int value.
{
return( (void *)(INT_PTR)i );
}
__inline
void *
UIntToPtr(
const unsigned int ui
)
// Caution: UIntToPtr() zero-extends the unsigned int value.
{
return( (void *)(UINT_PTR)ui );
}
__inline
void *
LongToPtr(
const long l
)
// Caution: LongToPtr() sign-extends the long value.
{
return( (void *)(LONG_PTR)l );
}
__inline
void *
ULongToPtr(
const unsigned long ul
)
// Caution: ULongToPtr() zero-extends the unsigned long value.
{
return( (void *)(ULONG_PTR)ul );
}
#define PtrToPtr64( p ) ((void * POINTER_64) p)
#define Ptr64ToPtr( p ) ((void *) p)
#define HandleToHandle64( h ) (PtrToPtr64( h ))
#define Handle64ToHandle( h ) (Ptr64ToPtr( h ))
__inline
void *
Ptr32ToPtr(
const void * POINTER_32 p
)
{
return((void *) (ULONG_PTR) (unsigned long) p);
}
__inline
void *
Handle32ToHandle(
const void * POINTER_32 h
)
{
return((void *) h);
}
__inline
void * POINTER_32
PtrToPtr32(
const void *p
)
{
return((void * POINTER_32) (unsigned long) (ULONG_PTR) p);
}
#define HandleToHandle32( h ) (PtrToPtr32( h ))
#endif // !_midl
#else // !_WIN64
#define ADDRESS_TAG_BIT 0x80000000UL
typedef unsigned short UHALF_PTR, *PUHALF_PTR;
typedef short HALF_PTR, *PHALF_PTR;
typedef _W64 long SHANDLE_PTR;
typedef _W64 unsigned long HANDLE_PTR;
#define HandleToULong( h ) ((ULONG)(ULONG_PTR)(h) )
#define HandleToLong( h ) ((LONG)(LONG_PTR) (h) )
#define ULongToHandle( ul ) ((HANDLE)(ULONG_PTR) (ul) )
#define LongToHandle( h ) ((HANDLE)(LONG_PTR) (h) )
#define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) )
#define PtrToLong( p ) ((LONG)(LONG_PTR) (p) )
#define PtrToUint( p ) ((UINT)(UINT_PTR) (p) )
#define PtrToInt( p ) ((INT)(INT_PTR) (p) )
#define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) )
#define PtrToShort( p ) ((short)(LONG_PTR)(p) )
#define IntToPtr( i ) ((VOID *)(INT_PTR)((int)i))
#define UIntToPtr( ui ) ((VOID *)(UINT_PTR)((unsigned int)ui))
#define LongToPtr( l ) ((VOID *)(LONG_PTR)((long)l))
#define ULongToPtr( ul ) ((VOID *)(ULONG_PTR)((unsigned long)ul))
#if !defined(__midl)
__inline
void * POINTER_64
PtrToPtr64(
const void *p
)
{
return((void * POINTER_64) (unsigned __int64) (ULONG_PTR)p );
}
__inline
void *
Ptr64ToPtr(
const void * POINTER_64 p
)
{
return((void *) (ULONG_PTR) (unsigned __int64) p);
}
__inline
void * POINTER_64
HandleToHandle64(
const void *h
)
{
return((void * POINTER_64) h );
}
__inline
void *
Handle64ToHandle(
const void * POINTER_64 h
)
{
return((void *) (ULONG_PTR) (unsigned __int64) h );
}
#endif
#define Ptr32ToPtr( p ) ((void *) p)
#define Handle32ToHandle( h ) (Ptr32ToPtr( h ))
#define PtrToPtr32( p ) ((void * POINTER_32) p)
#define HandleToHandle32( h ) (PtrToPtr32( h ))
#endif // !_WIN64
#define HandleToUlong(h) HandleToULong(h)
#define UlongToHandle(ul) ULongToHandle(ul)
#define UlongToPtr(ul) ULongToPtr(ul)
#define UintToPtr(ui) UIntToPtr(ui)
#define MAXUINT_PTR (~((UINT_PTR)0))
#define MAXINT_PTR ((INT_PTR)(MAXUINT_PTR >> 1))
#define MININT_PTR (~MAXINT_PTR)
#define MAXULONG_PTR (~((ULONG_PTR)0))
#define MAXLONG_PTR ((LONG_PTR)(MAXULONG_PTR >> 1))
#define MINLONG_PTR (~MAXLONG_PTR)
#define MAXUHALF_PTR ((UHALF_PTR)~0)
#define MAXHALF_PTR ((HALF_PTR)(MAXUHALF_PTR >> 1))
#define MINHALF_PTR (~MAXHALF_PTR)
//
// SIZE_T used for counts or ranges which need to span the range of
// of a pointer. SSIZE_T is the signed variation.
//
typedef ULONG_PTR SIZE_T, *PSIZE_T;
typedef LONG_PTR SSIZE_T, *PSSIZE_T;
//
// Add Windows flavor DWORD_PTR types
//
typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
//
// The following types are guaranteed to be signed and 64 bits wide.
//
typedef __int64 LONG64, *PLONG64;
//
// The following types are guaranteed to be unsigned and 64 bits wide.
//
typedef unsigned __int64 ULONG64, *PULONG64;
typedef unsigned __int64 DWORD64, *PDWORD64;
//
// Thread affinity.
//
typedef ULONG_PTR KAFFINITY;
typedef KAFFINITY *PKAFFINITY;
#ifdef __cplusplus
}
#endif
#endif // _BASETSD_H_
|
|
|
|
|
rat.crown wrote:
BaseTsd.h 9 KB 4/14/2005
Which could be anywhere from 8,704 to 9,727 bytes.
In any case, you need to examine the file more closely. Both ULONG_PTR and PDWORD_PTR are defined in the file. Look around lines 104, 114, 123, and 412.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Thank you. You fig out my mistake, Sorry for that!
But why I can not built the project? The error message is "rror C2065: 'PDWORD_PTR' : undeclared identifier" ?
I use the $inlcude statment as following... I think it sgould be OK.
#include "C:\Program Files\Microsoft Platform SDK\Include\BaseTsd.h"
Thanks
|
|
|
|
|
rat.crown wrote:
The error message is "rror C2065: 'PDWORD_PTR' : undeclared identifier" ?
Look at the various preprocessor directives (e.g., #if , #ifdef ) in that file. Those must evaluate to true in order for the typedef statements to get compiled.
rat.crown wrote:
#include "C:\Program Files\Microsoft Platform SDK\Include\BaseTsd.h"
Why not use this instead:
#include <BaseTsd.h>
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I got the reason, I have to change the VC/tools/option/directory!
Now every thing are OK. Thanks! Its my first using SDK.
|
|
|
|
|
Thank! I got some mistake. I forgort change the directore in the VC++ tools/option. Any way thank you for fig out my problem.
|
|
|
|
|
hi, all
I got debug assertion failure when the app hits \MFC\SRC\WINCORE.CPP, at function "void CWnd::AssertValid() const", line "ASSERT((CWnd*)p == this);"
#ifdef _DEBUG
void CWnd::AssertValid() const
{
if (m_hWnd == NULL)
return; // null (unattached) windows are valid
// check for special wnd??? values
ASSERT(HWND_TOP == NULL); // same as desktop
if (m_hWnd == HWND_BOTTOM)
ASSERT(this == &CWnd::wndBottom);
else if (m_hWnd == HWND_TOPMOST)
ASSERT(this == &CWnd::wndTopMost);
else if (m_hWnd == HWND_NOTOPMOST)
ASSERT(this == &CWnd::wndNoTopMost);
else
{
// should be a normal window
ASSERT(::IsWindow(m_hWnd));
// should also be in the permanent or temporary handle map
CHandleMap* pMap = afxMapHWND();
ASSERT(pMap != NULL);
CObject* p;
ASSERT((p = pMap->LookupPermanent(m_hWnd)) != NULL ||
(p = pMap->LookupTemporary(m_hWnd)) != NULL);
ASSERT((CWnd*)p == this);
the failure message comes up when p was point to "cWndhWnd" and this is "CUsoDlg".......since it's a multithread application, could this failed message just be ignored? it's debug assertion anyway.
thanks!
-- modified at 15:03 Tuesday 13th September, 2005
|
|
|
|
|
valerie99 wrote:
".......since it's a multithread, could this failed message just be ignored? it's debug assertion anyway.
Are you serious? When an assertion fires, it is indicating to you that something was encountered that was not expected and needs to be fixed. Just because you do not see it in Release mode does not mean that the problem does not exist.
At the point of the assertion, what does the stack trace look like?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Thanks for your replay, David
I have checked the app again, seems like most of the time, both p and this will point to "CUsocDlg", which is correct. Somepoint, P will points to "CWndhWnd", I am not sure where is this from....
CObject* p;
ASSERT((p = pMap->LookupPermanent(m_hWnd)) != NULL ||
(p = pMap->LookupTemporary(m_hWnd)) != NULL);
ASSERT((CWnd*)p == this);
the stack trace looks like it's at the end of the void CUsocDlg::Process() (it points to last '}')......it also at UINT ThreadFalling(LPVOID pParam) function, line "return 0"
|
|
|
|
|
valerie99 wrote:
the stack trace looks like it's at the end of the void CUsocDlg::Process() (it points to last '}')......it also at UINT ThreadFalling(LPVOID pParam) function, line "return 0"
When you double-click on an item in the Call Stack window, you are taken to the line immediately preceeding that line. It will be marked with a yellow arrow in the left margin. In your case, if that arrow is pointing to the closing curly brace, the statement right above that is the active one. Go back through the functions called, the ones for which you have the source, and note the state and value of the variables. You should be able to tell if a variable does not look right before a function is called with bogus data.
Here is a very basic article on how to use the debugging windows:
http://www.perfectxml.com/nr/aspnetdebug.pdf
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hello Friends,
I have 3 edit boxes in which I enter the values of RGB respectively. Whenever there is a change of value in the edit boxes, I display the appropraite color based on the inputted values in a picture control.
My main problem lies, if I resize the window, then the color displayed in the picture control is gone, so for displaying it again, i have to change the value of edit box.
So, please help me regarding this one so that even if i resize the window, the colour is shown to the user.
Even I had included OnPaint() function and calling the color display, then it is flickering.
Please help me.
Thanks in Advance.
|
|
|
|
|
Check for the WM_SIZE event (OnSize() function).
|
|
|
|
|
It sounds like you are just redrawing the control in a new color and not setting it to the new color. In orther words, you should be calling a function that changes the drawing color of the control so that when it is being repainted it uses the new color.
You should not need to define your own OnPaint() function to accomplish this.
The flickering is noramaly caused by the OnEraseBkgnd().
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hey,
can you please help me. I've created a CustomControl which draws a special table. No I want to implent a scroll-function. So I added the style WS_HSCROLL and handled the message. I'd use the ScrollWindow function. Now the table scrolls, but the "new area" is not filled correctly. There is the last column (before scrolled) smeared. Do I have to code a special OnDraw-function. I thought it is enough when I paint outside the client area and then scroll....
|
|
|
|
|
Hello everybody,
Im new in c++ and i have a problem because i have mfc program (client/server) where the client identidy the USB devices connected and i save this information in a txt file with this information:
{745A17A0-74D3-11D0-B6FE-00A0C90F57DA}
{483K23F8-74D3-11D0-B6FE-00A0C90F57DA}
and i want to know if this two usb devices are registered adn for this i use another text file in the server part whith all the usb registered that i want, for example:
{745A17A0-74D3-11D0-B6FE-00A0C90F57DA}
So if one usb is in the database i want to show a message that is registered. And i have this code but doesnt work, because dont show me the message:
void CIOCPClientDlg::compareFiles(){
char data[40];
std::ifstream fileusb ("GUIDs_found.txt");
char data2[40];
std::ifstream database ("C:\Documents and Settings\Densitet\My Documents\Visual Studio Projects\IOCP-SRC\IOCP-SRC\IOCP\Debug\USBDevices.txt");
bool salida =false;
while (!fileusb.eof() )
{
fileusb.getline(data,40);
while (!database.eof()&&(!salida==false))
{
database.getline(data2,40);
if (data==data2){
AfxMessageBox("USB registered");
}
salida=false;
}
}
}
If somebody can help me with this proble.
Than you for the possible help
|
|
|
|
|
Replace:
if (data==data2){
by that:
if (strcmp(data,data2) == 0){
What you are doing is comparing the two pointers which are of course different (the pointer data points to another location than the pointer data2).
|
|
|
|
|
Thank u for the help. I replaced that but i still can´t see the messagebox with USB registered so is any problem because i know that the information of the first file(data) is in the other file(data2), for sure. So i dont know what to do. Thank u.
|
|
|
|
|
densitet wrote:
std::ifstream database ("C:\Documents and Settings\Densitet\My Documents\Visual Studio Projects\IOCP-SRC\IOCP-SRC\IOCP\Debug\USBDevices.txt");
This won't work with single backslahes in a string literal.
Cedric has already given you a solution, but I have question. Since this is an MFC application, why are you using char instead of CString ? By changing data and data2 to CString , you can then do the more natural if (data == data2) comparison.
Also, for each line that you are reading from the fileusb object, you are looking for that line in the database object. That works fine for the first pass through the database object but I don't see where that object gets reset so that it can be searched again for the next line in the fileusb object.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|