|
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
|
|
|
|
|
I've got an old project writetd in vc++ on VS 7.1. When I opened it on Visual Studio 2008 it was correctly converted and worked. Now i needed to use a part of this old code in the new project created on VS2008. Everything work exepct a part of old code:
int CDGabinetDlg::DefineGrammar(const char* fn)
{
int rc;
SM_MSG reply;
TCHAR lpBuffer[256];
GetCurrentDirectory(256, lpBuffer);
string filename(lpBuffer);
filename+="\\";
filename+=fn;
return rc;
}
I've get an error in this part:
string filename(lpBuffer);
This is an error what i get.
error C2664: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string(const std::allocator<_Ty> &)' : cannot convert parameter 1 from 'TCHAR [256]' to 'const std::allocator<_Ty>
|
|
|
|
|
The difference between VC7 and VC8 (related to your error I mean) is that in VC2008, UNICODE is defined by default. If you want to better understand what that means, I suggest this article[^].
In your code snippet, you are not being consistent neither: sometimes you are using a char arrays, sometimes a TCHAR array. So, either you do not care at all about unicode and only use char array, or you care about UNICODE and use TCHAR arrays everywhere. But using both is ugly.
On the other hand, std::string do not support wide characters, so that's why you have the compilation error. For that part, if you want to support unicode builds, I suggest you define your own type:
#if defined _UNICODE || defined UNICODE
typedef std::wstring TMyString;
#else
typedef std::string TMyString;
#endif
This way, you'll be independant of the unicode settings.
|
|
|
|
|
Hey, I wanted to know that whether it is safe to use ADO in a DLL? The reason I'm asking this is that, to use ADO we need to initialize COM right? So calling CoInitialize in a DLL, is it okay?
|
|
|
|
|
Ahmed Manzoor wrote: we need to initialize COM right? So calling CoInitialize in a DLL, is it okay?
Yes. You do it and the matching uninitialize in DLLMain for every Process and Thread attach/detach message.
From the documentation:
Because there is no way to control the order in which in-process servers are loaded or unloaded, do not call CoInitialize, CoInitializeEx, or CoUninitialize from the DllMain function.
link[^]
|
|
|
|
|
What do you mean? Is it safe? Will there be any malfunction?
|
|
|
|