|
Take at look at this: http://www.codeproject.com/miscctrl/multiline_titletips.asp
Chen Venkataraman
|
|
|
|
|
Thanks! Problem solved
|
|
|
|
|
Hi,
Can anyone tell me how can I
open a Modal dialog , but that
is hidden ?
Thanks
San
|
|
|
|
|
Yes, use DoModal
In the InitDialog use ShowWindow with SW_HIDE.
Best Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Hello, the codegurus around the world.
Are you sure that ShowWindow (SW_HIDE) works?
I think that the controls on the dailog is hidden by ShowWindow (SW_HIDE)
, but the dialog isn't hidden by ShowWindow(SW_HIDE) in OnInitDialog().
In fact, I try to do this by myself, but this didn't work.
So, I use MoveWindow, and use the size of the dialog as zero.
(look like hidden )
Or, you are sure.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Masaaki Onishi wrote:
Are you sure that ShowWindow (SW_HIDE) works?
You are correct. For a modal dialog putting ShowWindow(SW_HIDE) in the OnInitDialog won't have the expected effect. But you can try this. Put this in the OnInitDialog.
SetTimer(5000,5000,0);
You can change the 5 seconds to 3 seconds or even 1 second. But don't make it lesser than that, because we need to make sure the dialog has comeup on screen.
Now in the OnTimer(UINT nIDEvent) do this :-
if(nIDEvent==5000)
ShowWindow(SW_HIDE);
You might want to use KillTimer to prevent the timer function being activated repeatedly and meaninglessly.
But mind you, once you've hidden the window, the user cannot do anything to it. I hope you are sure, this is what you wanna do, because I see no reason why anyone would want to hide their modal dialog.
Regards
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
Hello, the codegurus around the world.;)
Thanks, BusterBoy.
However, I have already implemented this kind of code in my project.
In my case, I use Timer to show the dialog hidden by MoveWindow
in OnInitDialog().
In fact, if the other ppl succeed in for the dialog hiding
by ShowWindow (SW_HIDE) in OnInitDialog(), I must consider that my code
may be something wrong with others in OnInitDialog().
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
A hidden modal dialog will make your app unusable, since modal means the parent window is disabled. So you'll end up with a disabled main window and no way to interact with the dialog.
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Actually the whole setup is like this
I am using Threads in a DLL
So the first window( Modal ) dialog is in a DLL opens
and creates thread which contains another window.
Now this window keeps sending messages to the Main
window and when the 2nd window completes it's task
it send message to the parent window to close everything.
So I have used a Timer in the main window to check
whether the 2nd window ( Modal child ) is closed, so a
flag informs the Main window that the child is closed,
then the main window closes itself. I need that the
user should not see the main window.
One of the major problem that I face is that the
Thread communication. I need that child window closes
itself and informs the Main or Parent window to close
itself. Timer was the only thing I could work out
If anyone has a better Idea , I would appreciate it.
Thanks
San
|
|
|
|
|
Hi !
I want to have a similar interface as the windows-explorer one, with a tree control on the left, a list on the right, with user-resizable width.
Anyone could give me some hints ? I tried to use a splitview application, derived from CListView, but how can I have a tree view on the left part of my app ?
Any help is welcome !
Thank you !!!
Jerome
|
|
|
|
|
Use the MFC App Wizard, A Advance option allows you to have an interface like Explorer.
|
|
|
|
|
Use a splitter window.
Derive the left view from CTreeView and the right view from CListView.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
Hi,
I'm developing an application that needs to be able to save reports in a variety of formats, namely HTML, Word and PDF formats. HTML is easy as its just a text file, Word is easy because of the automation, but i dont know how to handle the PDF format. Is there a tool that can convert HTML files to PDF, or Word files to PDF, or is there another way around this. I know that Acrobat 5.0 comes with this ability but i need something thats 'free' to distribute.
Cheers in advance,
Andy.
|
|
|
|
|
The guys from FyTek sell tools for dynamic PDF cration, and give away a free text to PDF converter.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
see this link
http://www.planetpdf.com/mainpage.asp?MenuID=85&WebPageID=898
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
Cheers Nish, thats just what i was looking for.
Andy.
|
|
|
|
|
I have developed a dialog box based application for a college project. But midway through the project, my professor wants me to have a menu bar in the application.
I have already written much code, so it would be a pain for me to start from scratch.
So I have 2 question:
q1)Is it possible to have a menu in a dialog box based application?
q2)If yes, then is there a way for me to add a menu bar to my existing project or create a new project and reuse all my existing dialog boxes, resources and code?
Thanks,
Mike
|
|
|
|
|
q1) and q2)
Sure, just create a menu with the resource editor, then go to the dialog properties, General tab, and there you have a combobox to select the menu associated with the dialog.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I ahve a dialog based app, in which I have the main dialog, and then I have a child window of the main dialog, which has a system menu. In my main dialog, the system icon is set by the framework, but I want to change the system icon of that child window as well, so both dialogs have the same system icon (the child window currently has the defualt windows icon). I found some information on MSDN, such as SetSystemIcon(), but for some reason, I can't get it to work. Either the icon shows up, or the program crashes. Anyone know how to do this?
|
|
|
|
|
Use CWnd::SetIcon.
Put it in the OnInitDialog of your child dialog.
If your child window is not a dialog, then put it in OnCreate.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
Hi,
all
I have loaded in a bitmap in my program.And I have draw
some lines on the bitmap .Now I want to store this new bitmap with lines on it. How should I do???
Expect your help.
|
|
|
|
|
Hi Bliven
I havent done much bitmap stuff.
But this URL might help you, I hope.
http://www.codeproject.com/bitmap/cximage.asp
Regards
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
Hi there! Below is my problematic dialog-based program that has 2 threads : the program's primary thread and a second thread.
This program has a pushbutton, and when clicked, a modal dialog box pops up.
The program downloads a specified file from the Internet to the user's hard disk.
Name of main program dialog class : CDownloaderDlg
Name of modal dialog class : CUpdateDlg
Below, is my code for showing the modal dialog box when the pushbutton is clicked in the main dialog :
"#include "UpdateDlg.h"
void CDownloaderDlg::OnUpdatenow()
{
//show the modal dialog box
CUpdateDlg dlg(this);
dlg.DoModal();
}
Now, after running the code above, a modal dialog box(CUpdateDlg) will pop up, right?
//*******Below is all my code for the UpdateDlg.cpp file.*********
//I link this program with the WinInet library, cos' it's required
// UpdateDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Downloader.h"
#include "UpdateDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//include afxinet.h header file
#include <afxinet.h>
const UINT WM_HTTPDOWNLOAD_THREAD_FINISHED = WM_APP + 1;
/////////////////////////////////////////////////////////////////////////////
// CUpdateDlg dialog
CUpdateDlg::CUpdateDlg(CWnd* pParent /*=NULL*/)
: CDialog(CUpdateDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CUpdateDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
//m_pThread is a CWinThread member variable
m_pThread = NULL;
//m_bSafeToClose is a BOOL member variable
m_bSafeToClose = FALSE;
}
void CUpdateDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUpdateDlg)
DDX_Control(pDX, IDC_STATUS_PERCENTAGE, m_Status_Percentage);
DDX_Control(pDX, IDC_STATUS_KB, m_Status_KB);
DDX_Control(pDX, IDC_DOWNLOADSTATUS, m_DownloadStatus);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUpdateDlg, CDialog)
//{{AFX_MSG_MAP(CUpdateDlg)
ON_BN_CLICKED(IDC_DOWNLOAD, OnDownload)
ON_WM_DESTROY()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_HTTPDOWNLOAD_THREAD_FINISHED, OnThreadFinished)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUpdateDlg message handlers
LRESULT CUpdateDlg::OnThreadFinished(WPARAM wParam, LPARAM /*lParam*/)
{
m_bSafeToClose = TRUE;
EndDialog(IDCANCEL);
return 0L;
}
//function for downloading a file from the Internet
//you don't realy need to know this function, though.
CString CUpdateDlg::DownloadFile(const char *url, const char *filename)
{
// Size of HTTP Buffer...
#define HTTPBUFLEN 512
char httpbuff[HTTPBUFLEN];
TCHAR szCause[255];
int nFileSize = 0;
CString Cause;
Cause.Format("YES");
TRY
{
CInternetSession mysession;
CStdioFile *remotefile = mysession.OpenURL(url,1,INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_RELOAD);
DWORD dwFileSize;
char szSizeBuffer[32];
DWORD dwLengthSizeBuffer = 32;
HINTERNET hFileInfo;
hFileInfo = InternetOpenUrl(mysession, url, NULL, 0, 0, 0);
BOOL bQuery = ::HttpQueryInfo(hFileInfo,HTTP_QUERY_CONTENT_LENGTH, szSizeBuffer, &dwLengthSizeBuffer, NULL) ;
if(bQuery)
{
dwFileSize = atol(szSizeBuffer);
::InternetCloseHandle(hFileInfo);
//store the file size in an int variables,
//and divide it by 1024 to convert it to KB.
nFileSize = dwFileSize / 1024;
//set the range of progress bar to the total file size
m_DownloadStatus.SetRange32(0,nFileSize);
}
else
{
MessageBox("Unable to retrieve file sizes!","Error",MB_OK | MB_ICONWARNING);
}
CFile myfile(filename, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
int numbytes = 0, nBytesTransfered = 0;
while(numbytes = remotefile->Read(httpbuff, HTTPBUFLEN))
{
//set the position accordingly in the progress bar
m_DownloadStatus.SetPos(nBytesTransfered / 1024);
}
}
CATCH_ALL(error)
{
error->GetErrorMessage(szCause,254,NULL);
Cause.Format("%s",szCause);
}
END_CATCH_ALL;
return (Cause);
}
UINT CUpdateDlg::_DownloadThread(LPVOID pParam)
{
//Convert from the SDK world to the C++ world
CUpdateDlg* pDlg = (CUpdateDlg*) pParam;
ASSERT(pDlg);
ASSERT(pDlg->IsKindOf(RUNTIME_CLASS(CUpdateDlg)));
pDlg->DownloadFile("http://www.geocities.com/xeon_boy/Dinos.zip","C:\\Windows\\Desktop\\ght.zip");
return 0;
}
void CUpdateDlg::OnDownload()
{
// TODO: Add your control notification handler code here
m_pThread = AfxBeginThread(_DownloadThread, this, THREAD_PRIORITY_NORMAL, CREATE_SUSPENDED);
m_pThread->m_bAutoDelete = FALSE;
m_pThread->ResumeThread();
}
void CUpdateDlg::OnCancel()
{
PostMessage(WM_HTTPDOWNLOAD_THREAD_FINISHED);
CDialog::OnCancel();
}
void CUpdateDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
if (m_pThread)
{
WaitForSingleObject(m_pThread->m_hThread, INFINITE);
delete m_pThread;
m_pThread = NULL;
}
}
void CUpdateDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
if(m_bSafeToClose)
{
CDialog::OnClose();
}
}
The thing is that when I run the program and the downloading process is half-way through
and I click the Cancel button(IDCANCEL , OnCancel), the modal dialog(CUpdateDlg) closes down
and everything is fine, but the main program HANGS and everything gets stucks! And I've to use
Alt + Ctrl + Del to close down the thing! Can you please help me? I've been trying this fro around 2 weeks and 3 days,
but just couldn't find the bug even after days and days of re-coding and testing and building and testing again.
Also, if you wish, I can send you the program for you to inspect, just give me your e-mail address.
Please help!!! Thanks a lot, really......in advance!
Good day,
Xeon
|
|
|
|
|
There are several little flaws in your code. The main problem is that the downloading thread does not provide any method for premature cancellation, so when you press cancel the program starts closing before it is safe to close the dialog.
I propose you follow this schema: Add a BOOL variable to indicate the thread to exit (m_bTimeToDie for instance), and have the downloading loop check for it. Then, change things according to this:
LRESULT CUpdateDlg::OnThreadFinished(WPARAM wParam, LPARAM )
{
m_bSafeToClose = TRUE;
EndDialog(IDCANCEL);
return 0L;
}
CString CUpdateDlg::DownloadFile(const char *url, const char *filename)
{
...
PostMessage(WM_HTTPDOWNLOAD_THREAD_FINISHED);
return (Cause);
}
void CUpdateDlg::OnCancel()
{
if(m_pThread){
m_bTimeToDie=TRUE;
GetDlgItem(IDCANCEL)->EnableWindow(FALSE);
}
else EndDialog(IDCANCEL);
}
void CUpdateDlg::OnDestroy()
{
if(m_pThread){
::WaitForSingleObject(m_pThread->m_hThread,INFINITE);
delete m_pThread;
m_pThread=NULL;
}
CDialog::OnDestroy();
}
void CUpdateDlg::OnClose()
{
if(m_bSafeToClose)CDialog::OnClose();
else{
if(m_pThread){
m_bTimeToDie=TRUE;
GetDlgItem(IDCANCEL)->EnableWindow(FALSE);
}
else EndDialog(IDCANCEL);
}
}
Hope this helps.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I need the window handle, having the ID Process, the ID Thread, the handle Process,and the handle Thread of the process that launch the application.
|
|
|
|
|