|
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?
|
|
|
|
|
Ahmed Manzoor wrote: Will there be any malfunction?
That depends on you, your analysis of your scenario and developing a correct solution. Make sure you read the documentation I provided a link to.
The best scenario is the host process has already handled COM initialization. If that isn't happening then you have a less than perfect scenario. Make sure you understand the ramifications and develop the proper error handling code for the potential scenarios that could occur based on your hosting scenario.
My fault, I should have mentioned that your scenario can also call for dealing with the initialization in other exports of your DLL rather than DLLMain. The problem with that is you need to account for the messages you get passed in DLLMain so that you know which event is happening. It's really up to you to figure all this out based on your project details.
|
|
|
|
|
Well now, I guess I would have to use another solution.
Thanks anyways
|
|
|
|
|
GetDlgItemText(id)->EnableWindow(FALSE) is not working in windows vista OS when user admin is off.I want to disable a groupbox in vista OS.
|
|
|
|
|
Do you want to disable the group box window? Why? After all its a static control
Or the controls within it?
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Hi All
i am creating a report which data take time 1-5mins. So i want to display a Please wait message.Please help me
|
|
|
|
|
You may perform the processing in a worker thread while displaying the wait message in the main (GUI ) one, see [^].
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]
|
|
|
|