|
hi
Does anyone know how to create html file from a c++ program (MFC)? I am working on a program where i have to generate a report from some database and should be able to print it. so i was thinking of creating report in html file which will be easier to format and print too. but i looked everywhere for some tutorials or any articles... no luck ..
have anyone done something similar? can someone help???
links for tuts or projects anything
thanks
zlich
|
|
|
|
|
The most basic way is to open a text file, write out HTML to it, and close it. If you don't know how to write HTML though, this isn't going to be too easy... but then, neither is anything else i could suggest. Some reporting packages will output to HTML, but if you're using a reporting package then you already have formatting/printing built-in.
Shog9
I'm not the Jack of Diamonds... I'm not the six of spades.
I don't know what you thought; I'm not your astronaut...
|
|
|
|
|
that.s not a very big task,just create the file name by using the .htm or .html extension,n then everything is as simple as creating a html page.for html you could check any site(lots of examples are available).
|
|
|
|
|
I'm trying to convert a Ctring that I read from an edit box into a float.
Here's the code I've got;
CString result;<br />
double d1;<br />
<br />
GetDlgItemText(IDC_EDIT1, result);<br />
char *txt = (char *) (LPCTSTR) result;<br />
d1 = atof(txt);<br />
When I display txt I do see the correct decimal number, unfortunately d1 is truncated after to the first digit. I.e. if I enter 26.5 in the edit box (IDC_EDIT1), txt is 26.5 but d1 is only 2.
What I am doing wrong here?
Is there any easier way of reading a float from an edit box?
Cheers,
Pat.
|
|
|
|
|
Try something along the lines of
sscanf(txt, "%f", d1);
txt is your string, d is your floating point.
|
|
|
|
|
Well you could always set a member variable for IDC_EDIT1 to a value as float. Thne no conversions would need to be made.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Thanks! I had done it originally but completely forgot to update the data, so it wouldn't work. It does now!!!
Cheers,
Pat.
|
|
|
|
|
Just for the sake of completness, I decided to throw this in after so many weeks:
Boost.org has its lexical cast http://www.boost.org/libs/conversion/lexical_cast.htm[^] which comes in handy whenever you are tempted to use those grizzled and outdated old C-library functions.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
i personally prefers sscanf_s function,its more reliable
|
|
|
|
|
How would I go about tracking mouse movement outside the window?
Currently OnMouseMove would only track the mouse within the windows.
|
|
|
|
|
- call GetCursorPos() in a loop (easy, but very bad idea)
- write a hook
- use DirectInput
there should be other possibilities, but those are the ones I remember right now.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Calling the SetCapture(HWND hWnd) API function will exclusivley send all mouse events to 'hWnd' regardless of whether they occur within the window or outside. Remember to call ReleaseCapture when done.
|
|
|
|
|
Hi people,
Maybe someone can help me. I have a CDialog derived class in a CToolbar, but I can't get the toolbar to resize to accomodate the dlg. Does anyone have an idea?
|
|
|
|
|
I've created a UI thread and I want my main app to send a message to it. So in my main app I make a call to PostThreadMessage.
In the message map of my UI thread I have:
<br />
BEGIN_MESSAGE_MAP(CMyThread, CWinThread)<br />
ON_THREAD_MESSAGE(UWM_STOPTHREAD, OnStopThread)<br />
END_MESSAGE_MAP()<br />
However when I post my message to the thread it never reaches the OnStopThread function that I created. Also I get an error if my function is set like this:
<br />
LRESULT CMyThread::OnStopThread(WPARAM wParam, LPARAM lParam)<br />
{<br />
AfxMessageBox("OnStopThread");<br />
m_sConnectSocket.Close();<br />
PostMessage(myHandle->m_hWnd,UWM_DISCONNECTED, 0, (LPARAM)&thdID);<br />
ExitInstance();<br />
return true;<br />
Where it returns an LRESULT. If I take this out and make it a void then it compiles fine but still does not work.
Here is the error I'm getting:
MyThread.cpp(55) : error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CMyThread::* )(WPARAM,LPARAM)' to 'void (__thiscall CWinThread::* )(WPARAM,LPARAM)'
I'm thinking of just putting a PeekMessage in the PreTranslateMessage and do my calls from here, but from what I've read on flounder.com, this is not a good idea.
Any suggestion please
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom,
here are two extracts from one of my class (I have removed all unrelated code) that does similar things and works well. Just verify you've got all declarations and definitions right. May be this will help.
Regards,
Serge Krynine
Header File:
class CLogDocument : public CWinThread
{
DECLARE_DYNAMIC(CLogDocument)
enum EThreadMessage
{
WM_ON_LOG_MESSAGE = WM_USER + 1000
};
afx_msg void OnLogMessage(WPARAM nWparam, LPARAM nLparam);
DECLARE_MESSAGE_MAP()
}; // class CLogDocument
Source File:
///////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNAMIC(CLogDocument, CWinThread)
///////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CLogDocument, CWinThread)
ON_THREAD_MESSAGE(EThreadMessage::WM_ON_LOG_MESSAGE, OnLogMessage)
END_MESSAGE_MAP()
///////////////////////////////////////////////////////////////////////
CLogDocument::~CLogDocument()
{
CWinThread::PostThreadMessage(WM_QUIT, 0, 0);
}
///////////////////////////////////////////////////////////////////////
bool CLogDocument::LogMessage(CString const& rstrMessage)
{
DWORD nResult = CWinThread::PostThreadMessage(EThreadMessage::WM_ON_LOG_MESSAGE,
reinterpret_cast<wparam>(pstrMessage),
NULL);
}
///////////////////////////////////////////////////////////////////////
void CLogDocument::OnLogMessage(WPARAM const nWparam, LPARAM const /*nLparam*/)
{
}
|
|
|
|
|
I have mine setup the same way, but it still does not work. The only difference is the way I'm posting my message to my thread...could that be it?
<br />
if (!PostThreadMessage((DWORD)hdi.lParam, UWM_STOPTHREAD, 0 , 0))<br />
{<br />
CString MyMsg;<br />
MyMsg.Format("Error posting message to thread: %s", m_lClientConn.GetItemText(i, 3));<br />
AfxMessageBox(MyMsg);<br />
}<br />
I'm going to try it your way and see if it makes a difference.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Hi.
In a CScrollView as far as I realised the GetClientRect returns the size of the physical page of the view. Howe can I alter programatically that size? How can I expand the client area to fit a larger design? What will happen with the co-ordinate system and how do I correct it?
Pls help as I am desperate to deliver something Thanks
|
|
|
|
|
Try this. Call GetClientRect, alter the coordinates, then call MoveWindow to update.
Some people see things that are and ask, Why? Some people dream of things that never were and ask, Why not? Some people have to go to work and don't have time for all that ...
Author: George Carlin
|
|
|
|
|
What are you trying to accomplish here? If you change the size of your window, the size of the client changes also. By default, the client is the size of the window, less borders, scrollbars, etc. - if you wish to make it smaller, that is possible, but it is not possible for the client area to ever be larger than the size of the window. Seeing as you're working with a CScrollView , you probably want SetScrollSizes() or some such.
Shog9
I'm not the Jack of Diamonds... I'm not the six of spades.
I don't know what you thought; I'm not your astronaut...
|
|
|
|
|
Hello
I need a ListBox that will provide functionality of both single selection and multiple selection listboxes. That means I should be able to singly or multiply make selections in a listbox. I develop with Visual c++ 6.0. What would you suggest ? How would one make it ? I need not to play with colors or anything else. Any help would be greatly appreciated.
Nice Ozgurce
|
|
|
|
|
Nice Özgürce wrote:
That means I should be able to singly or multiply make selections in a listbox.
Why the fuss? A multiselect listbox can do both. Otherwise, you'll need to create both controls on the dialog's template and hide/show each accordingly.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
You are right. I am just a newbie.
I have another simple question which I am sure you could easily give a solution.
suppose ; I have a dialog and on this dialog there is a editbox(say m_edit1) and a button. When I enter some text in this editbox(m_edit1) and push the button, I want this action(buttons onclick event) to create a popup window on which there is an editbox(say m_edit2) to be filled with the information(text, string whatever) sent from the parent dialog(the info provided thru m_edit1).
What should I do ?
Should I declare m_edit1 public, private or what ?
Should I include first class's header file in the popup window ?
What should I write to pass the m_edit1's text into popup's m_edit2.text ?
Thank you for your help
Nice Özgürce
|
|
|
|
|
class dialog2 : CDialog
{
public:
CString str;
private:
CEdit edit;
};
BOOL dialog2::OnInitDialog()
{
edit.SetWindowText(str);
} In the button handler:
dialog2 dlg;
dlg.str = text_from_the_edit_control;
dlg.DoModal();
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I do that in a dialog I use when sometimes I need to limit the user to one selection. In OnInitDialog, I just add this code based on a parameter which is set by the calling code.
if (m_bSingleSelection)
m_lbxSymbols.ModifyStyle(0, LVS_SINGLESEL);
else
m_lbxSymbols.ModifyStyle(LVS_SINGLESEL, 0);
This will turn multiselect on and off. Set the original style in the resource editor to multiselect.
Some people see things that are and ask, Why? Some people dream of things that never were and ask, Why not? Some people have to go to work and don't have time for all that ...
Author: George Carlin
|
|
|
|
|
How can i learn using PerformanceGraph ...it is very important... if you know any document or article!!
|
|
|
|