|
Folks,
I have a VERY OLD legacy app that I'm trying to compile under VS 2008 (I am NOT an MFC developer at all).
I am running into build errors on things like:
<br />
template <> void AFXAPI ConstructElements <SubjectUsage> (SubjectUsage * pSubName, int nCount)<br /> NOTE: Edited this to correct the line
ERRORS for this is:
C2143 Syntax error: missing ";" before "<"
C2182: "ConstructElements: illegal use of type 'void'
C2988: unrecognizable template declaration/definition
I know NOTHING about the AFXAPI, but the file does have an
<code>#include <afxtempl.h> </code>
Any help greatly appreciated, and in general, any words of wisdom from moving from VC++6 to VS2008?
modified on Wednesday, May 20, 2009 2:06 PM
|
|
|
|
|
gartnerj wrote: template <> void AFXAPI ConstructElements (SubjectUsage * pSubName, int nCount)
There appears to be something missing from this statement. Try clicking the "Do not interpret HTML..." checkbox, and use the Verify button.
gartnerj wrote: C2143 Syntax error: missing ";" before "<"
It looks as though the compiler does not know what SubjectUsage is.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Well, I didn't include all of the code, but the SubjectUsage class is defined right above this line in the file, so that shouldn't be an issue.
This code DOES compile in Visual C++ 6.0. I'm sure there must be differences with C++ and with the MFC supplied with VS 2008 that is causing this -- not sure if there are any project switches to set for compatibility?
Also, the CORRECT statement that has the errors is:
template <> void AFXAPI ConstructElement <SubjectUsage> (SubjectUsage * pSubUsage, int nCount)
Sorry about that!
|
|
|
|
|
|
Thanks -- I did read those pages, but not a lot of info on using old MFC with VS 2008.
|
|
|
|
|
gartnerj wrote: but not a lot of info on using old MFC with VS 2008.
Yes but old MFC is just C++. Stuart has provided the pinpoint documentation for you so you can move on. If you find other problems they will be similar because VC6 did not fully implement the C++ Standards. I don't believe 2008 does either but it implements much more which can produce compiler errors in old code due to the compiler enforcing more standards. Each version of VC since 6 has been more compliant so as in this example the documentation might be version specific since it was changed in a specific version.
|
|
|
|
|
Thanks -- yeah that link really helped!
I guess I was hoping that there would be some sort of compatibility mode setting for the compiler/project to allow this to work with minimal change, but I don't think that's possible!
|
|
|
|
|
This page[^] tells you what to do - basically, don't use ConstructElements any more!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks -- VERY helpful!!!
|
|
|
|
|
hi there,
I have compiled a string table and some of the strings I need to assign to a char* variable, how can I do it?
Thanks
Jim
|
|
|
|
|
What about LoadString [^] function?
(LPTSTR resolves to char * for a ANSI build)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: (LPTSTR resolves to char * for a ANSI build)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
On the picture control ,I mean to move the rectangle through the mousemove.
how to make it? the picture control contains a picture and a small rectangle is on it.
|
|
|
|
|
If you use of CStatic you can derived your class of it and then declare WM_MOUSEMONE on it or you cna do it of your main class.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
In this days i'm writing a software to use for recovery PC. My software is complete but i need a progress bar moves during file extraction, i am trying but in 10 days nothing. How i can solve??? i post only the complete wim code. Please help me
// WimApplyProgressDlg.cpp : file di implementazione
//
#include "stdafx.h"
#include "WimApplyProgress.h"
#include "WimApplyProgressDlg.h"
#include <wimgapi.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
CProgressCtrl *Progress = new CProgressCtrl;
CWimApplyProgressDlg::CWimApplyProgressDlg(CWnd* pParent /*=NULL*/)
: CDialog(CWimApplyProgressDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CWimApplyProgressDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CWimApplyProgressDlg, CDialog)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDOK, &CWimApplyProgressDlg::OnBnClickedOk)
END_MESSAGE_MAP()
// gestori di messaggi di CWimApplyProgressDlg
BOOL CWimApplyProgressDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Impostare l'icona per questa finestra di dialogo. Il framework non esegue questa operazione automaticamente
// se la finestra principale dell'applicazione non è una finestra di dialogo.
SetIcon(m_hIcon, TRUE); // Impostare icona grande.
SetIcon(m_hIcon, FALSE); // Impostare icona piccola.
Progress->Create(WS_CHILD | WS_VISIBLE, CRect(10, 10, 288, 35), this,0x16);
Progress->SetRange(1, 100);
Progress->SetPos(0);
return TRUE; // restituisce TRUE a meno che non venga impostato lo stato attivo su un controllo.
}
// Se si aggiunge alla finestra di dialogo un pulsante di riduzione a icona, per trascinare l'icona sarà necessario
// il codice sottostante. Per le applicazioni MFC che utilizzano il modello documento/visualizzazione,
// questa operazione viene eseguita automaticamente dal framework.
void CWimApplyProgressDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // contesto di dispositivo per il disegno
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Centrare l'icona nel rettangolo client.
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Disegnare l'icona
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// Il sistema chiama questa funzione per ottenere la visualizzazione del cursore durante il trascinamento
// della finestra ridotta a icona.
HCURSOR CWimApplyProgressDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
DWORD WINAPI ApplyCallback(DWORD msgId,WPARAM param1,LPARAM param2,void *unused)
{
//First parameter: full file path for if WIM_MSG_PROCESS, message string for others
TCHAR *message = (TCHAR *) param1;
TCHAR *filePath = (TCHAR *) param1;
int percent = (int) param1;
//Second parameter: message back to caller if WIM_MSG_PROCESS, error code for others
DWORD errorCode = param2;
DWORD *msg_back = (DWORD *) param2;
switch ( msgId )
{
case WIM_MSG_PROGRESS:
Progress->SetPos(percent);
break;
}
return WIM_MSG_SUCCESS;
}
void CWimApplyProgressDlg::OnBnClickedOk()
{
HANDLE hWim = NULL, hImg = NULL;
// Get source, destination strings and other info
WCHAR wimFile[MAX_PATH] = L"C:\\boot.wim";
FARPROC callback = (FARPROC) ApplyCallback;
//Create the WIM file
DWORD created;
hWim = WIMCreateFile(wimFile, WIM_GENERIC_READ, WIM_OPEN_EXISTING,WIM_FLAG_VERIFY, 0, &created);
if (!hWim) {
MessageBox("Impossibile trovare il file WIM", "Errore", MB_OK | MB_ICONEXCLAMATION);
WIMCloseHandle(hWim);
return;
}
if (WIMRegisterMessageCallback(hWim,callback,NULL ) == INVALID_CALLBACK_VALUE) {
MessageBox("Callback error","Errore",MB_OK | MB_ICONEXCLAMATION);
return;
}
WCHAR tempDir[MAX_PATH] = L"C:\\mounted_wim";
if (!WIMSetTemporaryPath(hWim, tempDir)) {
MessageBox("Impossibile impostare la cartella di lavoro","Errore",MB_OK | MB_ICONEXCLAMATION);
WIMCloseHandle(hWim);
return;
}
hImg = WIMLoadImage ( hWim, 1 );
if ( !hImg ) {
MessageBox("Non posso caricare l'immagine", "Errore", MB_OK | MB_ICONEXCLAMATION);
WIMCloseHandle(hWim);
WIMCloseHandle(hImg);
return;
}
if (!WIMApplyImage(hImg, L"Y:\\",0)) {
MessageBox("Applying image failed","Error", MB_OK | MB_ICONEXCLAMATION);
WIMCloseHandle(hWim);
WIMCloseHandle(hImg);
return;
}
OnOK();
}
with this code all is blocked if i remove the item "Progress->SetPos(percent);" all go ok but without progress bar moving.
|
|
|
|
|
You need to put your lenghty processing in a separate thread. Here[^] is an excellent article that will get you started about threading.
|
|
|
|
|
Hi i have created a Dialog which contains the two buttons OK and CANCEL . But when i resize the dialog these button stick to their original position and does not change . I want these buttons to be on Botton Right Corner of my dialog . In my code i have done this
.
AddAnchor (IDC_HPCR_WO_OK ,BOTTOM_CENTER );
AddAnchor (IDC_HPCR_WO_CANCEL ,BOTTOM_LEFT );
Please provide any comments on this
|
|
|
|
|
Which library are you using, because there's no such support as AddAnchor in the MFC ?
|
|
|
|
|
Are you using CResizableDialog[^]? You could use the message board at the bottom of the article to ask your query. The author of the class himself may respond to you in that case.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi ,
Yes I am using CResizingDialog . Now what i did is i have writte a message handler
MESSAGE_HANDLER( WM_SIZE, OnSize )
but i didnt provide its implementation. My class is derived from CResizingDialog . Now buttons are changing their position as i required. But still not understood how it is working. Is it calling CResizingDialog :: OnSize () in this case ..?
|
|
|
|
|
pandit84 wrote: Please provide any comments on this
See the Extras section of this article.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi All
How can i set dialog size at the run time?Plz help me
|
|
|
|
|
|
If you plan to have controls on your dialog and resize or move them based on the size of the dialog you may want to use a layout library like this one: CResizableDialog[^]
Nuri
|
|
|
|
|
Have you looked at SetWindowPos() or MoveWindow() ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|