|
I have Printpreview difficult.
I want from doc/view facilities, to preview all I need to print.
According to all theories I read, i must create my View class derived from CPreviewView, but in my Visual C++ Standard Edition 6.0, i don't have it. how to do now ?
Would you like to send me this library ? (lib file).
Urgent
I learn my self
|
|
|
|
|
CPreviewView is declared in AfxPriv.h and it's implementation is in ViewPrev.cpp. You should have both those files.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Where to find those files, I need them.
And to use it to create my View class from them.
Or send me only the lib of this class
I learn my self
|
|
|
|
|
Please Sir, T say that I am using Visual c++ 6.0 standard edition. I thing that's my problem, if perhaps i had professionnal edtion, I would resolve my problem, so i ask if it is possible to send me this class like a librairy to incorporate it to my project.
Thanks
I learn my self
|
|
|
|
|
The files are included in the edition you have. AfxPriv.h is in the VC98/MFC/Include/ folder and ViewPrev.cpp is in the VC98/MFC/SRC folder.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
A create a new project. And I create a new view derived from CPreviewView.I insert Afxpriv.h and Viewprev.cpp files in my project.
Now I have this error message :
c:\Program Files\Microsoft Visual Studio\Vc98\Mfc\Src\Viewprev.cpp(169) : error C2491: 'CPreviewView::messageMap' : definition of dllimport static data member not allowed.
What to do ?
I learn my self
|
|
|
|
|
Do not add viewprev.cpp to your project. The file has already been compiled into the MFC42.dll file that contains all the MFC binaries. The file is include with VC so that you can step through it when debugging and/or so that you can read the source to see how MFC is implemented. That goes for all files in the VC98/MFC/SRC/ folder.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks,
I have now derived my view class from CPreviewView. And I add a command handler UI OnFilePreview()like this :
if (!DoPrintPreview(AFX_IDD_PREVIEW_TOOLBAR, this,
RUNTIME_CLASS(CPreviewView), pState))
{
// In derived classes, reverse special window handling
// here for Preview failure case
TRACE0("Error: DoPrintPreview failed");
AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
delete pState; // preview failed to initialize,
// delete State now
}
But it not works well. Not Toolbar menu and it hang also
I learn my self
|
|
|
|
|
I have seen again that DoPrintPreview() is not CPreviewView function.
What to do now to make a printpreview ?
I learn my self
|
|
|
|
|
Hi
I have a RS232 problem. I can initiate the COM1 handle. But when I try to read or write, it just hangs there - look like deadlock. How can I solve this problem?
Thank you very much,
|
|
|
|
|
Could it be a handshaking problem? This is very common so make sure flow control is turned off since it has to be working at both ends.
The tigress is here
|
|
|
|
|
Thank you very much for your reply. I double check the flow control setting.
I am using "PJ Naughter" Serial class. like:
CSerialPort::GetDefaultConfig(1, config);
CSerialPort port;
port.Open(1, 9600, CSerialPort::NoParity, 8, CSerialPort::OneStopBit, CSerialPort::NoFlowControl);
HANDLE hPort = port.Detach();
port.Attach(hPort);
DWORD dwModemStatus;
port.GetModemStatus(dwModemStatus);
DCB dcb;
port.GetState(dcb);
dcb.BaudRate = 9600;
port.SetState(dcb);
DWORD dwErrors;
port.ClearError(dwErrors);
port.SetBreak();
port.ClearBreak();
COMSTAT stat;
port.GetStatus(stat);
COMMTIMEOUTS timeouts;
port.GetTimeouts(timeouts);
port.Setup(10000, 10000);
port.GetConfig(config);
config.dcb.BaudRate = 9600;
port.SetConfig(config);
port.Set0WriteTimeout();
port.Set0ReadTimeout();
char sBuf[] = "This should appear on the serial port";
port.Write(sBuf, strlen(sBuf)); -------------------------> Stop here
What kind of reason cause this problem?
Thank you very much!
|
|
|
|
|
I assuem you have tried iusing Hyperterminal, To make sure the comms link is working oK? e.g. that he cable is OK etc.
"An education isn't how much you have committed to memory, or even how much you know. It's being able to differentiate between what you do know and what you don't." - Anatole France
|
|
|
|
|
I have a sample application that is registering for the notification of the file-create . I am using SHChangeNotifyRegister API to get the notifcation . Since my appln is to be supported in 98/me i haved used this . But when i copy around 50 files .. .. I am getting notification of only 20 files .. .I have attached the code for your reference
Header file
#define WM_USER_MEDIACHANGED WM_USER+88
// For the Shell notifier, to indicate the type of events for which to receive
// notifications.
#define SHCNF_ACCEPT_INTERRUPTS 0x0001
#define SHCNF_ACCEPT_NON_INTERRUPTS 0x0002
#define SHCNRF_RecursiveInterrupt 0x1000
typedef struct {
DWORD dwItem1; // dwItem1 contains previous PIDL or name of the folder.
DWORD dwItem2; // dwItem2 contains the new PIDL or name of the folder.
} SHNOTIFYSTRUCT;
// Memeber Functions.
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
.cpp file
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MSG Msg;
HWND hWnd;
WNDCLASSEX WndClsEx;
ULONG l_ulSHChangeNotifyRegister;
const char *ClsName = "BasicApp";
const char *WndName = "A Simple Window";
// Create the application window
WndClsEx.cbSize = sizeof(WNDCLASSEX);
WndClsEx.style = CS_HREDRAW | CS_VREDRAW;
WndClsEx.lpfnWndProc = WndProcedure;
WndClsEx.cbClsExtra = 0;
WndClsEx.cbWndExtra = 0;
WndClsEx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClsEx.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndClsEx.lpszMenuName = NULL;
WndClsEx.lpszClassName = ClsName;
WndClsEx.hInstance = hInstance;
WndClsEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
//BY_HANDLE_FILE_INFORMATION handle;
// Register the application
RegisterClassEx(&WndClsEx);
hWnd = CreateWindow(ClsName,
WndName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if( !hWnd ) // If the window was not created,
return 0; // stop the application
// Display the window in hidden mode.
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);
// Get the folder locations of the folders to be monitored using the CSIDL_XXXX values and
// store it in the identifiers list.
LPITEMIDLIST ppidl = NULL;
if(SHGetSpecialFolderLocation(hWnd, CSIDL_DRIVES , &ppidl) == S_OK)
{
SHChangeNotifyEntry shCNE;
shCNE.pidl = ppidl;
shCNE.fRecursive = TRUE;
// Returns a positive integer registration identifier (ID).
// Returns zero if out of memory or in response to invalid parameters.
l_ulSHChangeNotifyRegister = SHChangeNotifyRegister(hWnd,// Hwnd to receive notification
SHCNF_ACCEPT_INTERRUPTS | SHCNF_ACCEPT_NON_INTERRUPTS|SHCNRF_RecursiveInterrupt ,
// Events of interest - use
SHCNE_CREATE,
// Notification message to be sent when the event has occured
WM_USER_MEDIACHANGED,
// Number of entries in the pfsne array should always be 1
1,
// Array of SHChangeNotifyEntry structures that
// contain the notifications.
&shCNE);
}
else
{
// Log error in retrieving folder info of system.
}
while( GetMessage(&Msg, NULL, 0, 0) )
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
// Window call back function
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg,
WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_DESTROY:
arr.Format("%d",nCount);
MessageBox(NULL,arr,"Message",MB_OK);
PostQuitMessage(WM_QUIT);
break;
case WM_USER_MEDIACHANGED:
switch(lParam)
{ case SHCNE_CREATE: //File create
if (TRUE == SHGetPathFromIDList((struct _ITEMIDLIST *)shNotifyStr->dwItem1, sourcePath))
{
nCount++; }
break;
default:
break;
}
default:
// Process the left-over messages
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}
|
|
|
|
|
For performance reasons, multiple notifications may be combined into a single notification.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
thanks . You mean to say for performance reason Windows OS itself is giving only few notifications ? . Is there anyway to overcome this problem .
|
|
|
|
|
ragavan wrote:
You mean to say for performance reason Windows OS itself is giving only few notifications ?
That's exactly what I'm saying.
ragavan wrote:
Is there anyway to overcome this problem .
What problem?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I had asked yesterday if there was a way to look at all the files in a directory and I was directed to CFileFind, but for some reason, as I use .FindNextFile() and .GetFileName(), it's skipping like 4 files every time! Any help?
Danny
|
|
|
|
|
|
Actually, I have to retract that question. It does seem to search all the files, just in a different order than I would have expected. It does seem, though, that when I try to open the file just after I found it that the file doesn't open.
Here's the code I'm working with...
CFileFind finder;
BOOL bWorking = finder.FindFile(searchPath);
while (bWorking)
{
bWorking = finder.FindNextFile();
fileList[counter] = (LPCTSTR) finder.GetFileName();
path = (LPCTSTR) finder.GetFilePath();
examine.open(path, ios::in | ios::nocreate | ios::noreplace);
.
.
.
}
(fileList is an array of CStrings, path is a CString, and examine is an fstream.)
Is the finder possibly interfering with opening the file?
Danny
|
|
|
|
|
bugDanny wrote:
fileList[counter] = (LPCTSTR) finder.GetFileName();
path = (LPCTSTR) finder.GetFilePath();
While not related to the actual problem, the two casts are unnecessary.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
The order you see is dependant upon the underlying file system. For NTFS, you will generally see the files in alphabetical order by name. For FAT32, it's in 'directory' order, which is generally the order in which the files were added to the directory.
bugDanny wrote:
Is the finder possibly interfering with opening the file?
Doubtful. Try debugging your examine.open function with a hand-entered, known good file path.
Software Zen: delete this;
|
|
|
|
|
Dear Community,
I have a question about integration of context sensitiv help for dialogs in a vc++ developed application. I use a window with several tabs and like to provide help for the tabdialogs. Every tab obtained a contextid and the contextid is compiled into the chm-helpfile. I display the contextid of the called tabdialog after pressing F1 in a message window.
Only the first tab starts the help and displayes the context id, when I hit F1 oder use the "What is" function. The helpfilecall of all other tabs, if they are active, dos not work and no contextid is displayed. Can anyone tell me what's the reason for?
Thanks in advance for help.
Heyerdahl
|
|
|
|
|
I'm writing a C++ DLL to speed up (run time over 1 hour) an excel macro. I read arrays in the macro, pass them to the DLL as SAFEARRAYs, identify the memory location, assign it to a new C++ array. I read some of the arrays and write to others. Then the excel macro reads the arrays and writes the results to a spreadsheet.
An early version of the program ran OK (50,000 loops through the arrays) -- after some early problems -- and the results were correct (I verified them manually in excel). The run time was reduced by a factor of over 10 !!!.
Then I expanded the program and now it freezes up -- never at the same place but always on the same type of command and always a memory access violation, either assigning the pointer to the C++ array or reading from/writing to the array.
The code looks like this:
In excel macro:
Code:
Option Explicit
Option Base 0
Public CF() As Double, IssuerCorrel() As Double, CRN() As Double, TransitionIndex() As Integer, TransCutoff(0 To 6, 0 To 7) As Double, IssuerEndRatingCode() As Integer
Declare Sub Cholesky Lib “C:\CreditRisk\CreditSim.dll” (IssuerCorrel() As Double, CF() As Double, ByVal IssuerCount As Integer)
Sub ScenarioGenerator()
Application.Calculation = xlCalculationManual: Application.ScreenUpdating = False: Application.EnableEvents = False
Dim IssuerCount As Integer,
Read in some data from spreadsheets
Dim IssuerCorrel(IssuerCount, IssuerCount) as Single; CF(IssuerCount, IssuerCount) as Single
Read more data from spreadsheets
Call Cholesky(IssuerCorrel(), CF(), ByVal IssuerCount)
Write some output data to spreadsheets
End Sub
In C++:
Code:
#include "stdafx.h"
#include <windows.h>
#include <oleauto.h>
#include "CreditSim.h"
#include "Oaidl.h"
#include <stdlib.h>
#include <math.h>
#include <time.h>
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
void __declspec (dllexport) __stdcall Cholesky(
SAFEARRAY **IssuerCorrel, SAFEARRAY **CF, short IssuerCount)
{
double L = 0.999999;
short n = IssuerCount;
long i = 0;long j = 0; long k = 0;
srand( (unsigned) time( NULL ) );
HRESULT SafeArrayLock( SAFEARRAY **IssuerCorrel );
HRESULT SafeArrayLock( SAFEARRAY **CF );
// Create new arrays that point to the Safearray data locations
double* CFc;
CFc = (double*)(*CF)->pvData;
CFc[0]= *CFc; Program fails here.
double* IssuerCorrelc;
IssuerCorrelc = (double*)(*IssuerCorrel)->pvData;
IssuerCorrelc [0] =*IssuerCorrelc; Program fails here.
CFc[n*(n-1)+n-1] = IssuerCorrelc[n*(n-1)+n-1];
for (j = n-2; j>=0; j--)
{
CFc[n*j + j] = IssuerCorrelc[n*j + j];
for (k = n-1; k>j; k--)
{
CFc[n*j + k] = IssuerCorrelc[n*j + k] * L;
for (i = k + 1; i
|
|
|
|
|
When you call function Cholesky you should have at more than zero element in the array IssuerCorrel and CF. Try to check that before calling because when array is 0 you have failure.
|
|
|
|
|