|
Stephen Hewitt wrote: I tried it just then and you are correct, it doesn't work
Even I kept trying for sometime.
What puzzles me is that what purpose does it accomplish?
Jesus Loves <marquee direction="up" height="40" scrolldelay="1" step="1" scrollamount="1" style="background:#aabbcc;border-bottom:thin solid 1px #6699cc">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
I found myself wondering the same thing.
Steve
|
|
|
|
|
Respected All
Regards!
i developed aclass of printing, it works fine but the print did not come on the middle of the page,that's start from the TOP LEFT margine of the page,plz mentioned the changes so that i may able to get the print on the center of the page.
Thanks n advance.
David
david
|
|
|
|
|
Following the "brute force and pig-ignorance" approach, I do the following to print an image (C code, but it should give the idea):
iPageX = GetDeviceCaps (hdcPrn, HORZRES) ;
iPageY = GetDeviceCaps (hdcPrn, VERTRES) ;
iTopMargin = iPageY / 10;
iLeftMargin = iPageX / 10;
iPageX = iPageX - iLeftMargin - iLeftMargin;
iPageY = iPageY - iTopMargin - iTopMargin;
StretchDIBits(hdcPrn, iLeftMargin, iTopMargin, iPageX , iPageY,
0, 0, iImageMaxX, iImageMaxY, lvpBits, lpBitMapHeader,
DIB_RGB_COLORS, SRCCOPY);
I hope I haven't missed any relevant steps!
|
|
|
|
|
hi
how should i handle keystrokes in a dialog???
i handle them with PreTranslateMessage() but it seems that it handles a single keystroke for example twice or more! so the code executes more than once. what should i do??
i do sth like this:
PreTanslateMessage(MSG*msg)
{
switch(msg->wpraram)
{
case VK_UP:
//do the code
}
}
but the code executes more than once
|
|
|
|
|
In most cases handling them in PreTranslate message is unusual. If you want to however the code should look something like this:
<br />
PreTanslateMessage(MSG*msg)<br />
{<br />
if ( msg->message == WM_CHAR )<br />
{<br />
switch(msg->wpraram)<br />
{<br />
case VK_UP:<br />
}<br />
}<br />
}<br />
Steve
|
|
|
|
|
hamidreza_buddy wrote: switch(msg->wpraram)
{
case VK_UP:
//do the code
}
switch(msg->wpraram)
{
case VK_UP:
return TRUE;
}
return FALSE;
Now it will process only once.
Jesus Loves <marquee direction="up" height="40" scrolldelay="1" step="1" scrollamount="1" style="background:#aabbcc;border-bottom:thin solid 1px #6699cc">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Hi,
I need to buy a developer kit from a third party
software company. Since I'm developing my application
with VC++. So, it makes sense to buy the C++ developer kit.
That software company got developer kit in Jave, .Net, VB,
& a C++/ActiveX demo code.
I compiled and ran the C++ demo code but still a bit confused.
I probably will call that company tomorrow morning to
ask some questions.
But I wonder, normally, how the people use ActiveX?
In what situation?
Is that mainly for www application?
http://www.active-x.com/articles/whatis.htm
Maybe someone can share his/her knowledge with me?
Thanks,
Kevin
Kevin
|
|
|
|
|
ActiveX are components that can be used in any language (but of course, this is a Microsoft technology). You can also use them as a component in a Word or excell sheet...
It is not necessarily for web applications.
Typical examples of ActiveX are for example the MSFlexGrid (a grid control), some calendar controls, graph controls, ...
ActiveX files (ocx files) are in fact "enhanced dll's" that means this is a standard dll format files with some default functionnlity that allozs you to retrieve and use objects inside it.
Hope things are clear 
|
|
|
|
|
Hi,
Is there a way to make your button curved? I'm not using .NET, just plain visual c++ and mfc.
Thanks for all the help.
waxie![Rose | [Rose]](https://codeproject.global.ssl.fastly.net/script/Forums/Images/rose.gif)
|
|
|
|
|
I think the buttons can be made curved using SetWindowRgn(...) . You can first create the region using CreateEllipticRgn(...) or something like that.
If the result is not what you want then combining regions with owner-draw buttons will do it. There are lots of owner-draw buttons here on CP.
this is this.
|
|
|
|
|
Hi,
I have a win-app. In the program, there is a time, I need to have dialog window, so that user can browse and select input file for the program. Do you know any simple and quick way to creat such thing?
Also, I need to add in a program a simple registration dialog, any suggestion and example how to do that?
Thank in advance
Jim
Jim
|
|
|
|
|
To browse a file, you can use CFileDialog fd(TRUE);
then
int nResult = fd.DoModal();<br />
if (nResult == IDOK)<br />
{<br />
CString strPath = fd.GetPathName();<br />
}
Now strPath has the full path to the selected file.
To create some registration dialog, there are many ways to do it. It depends on what kind of registration you want to set.
If you do not want the user to run the program even once without registration, then you can:
Read a particular location from registry for the software key. If that key is read ok, then good. Else show a registration dialog like this:
Create a dialog resource. Attach a class to it, put a editbox on it. If the software is not registered, then create this dialog:
CRegDialog reg;<br />
reg.DoModal();
Now check the value the user entered into the editbox. If it is really the key, then save it to the registry at that particular location, and go on with the program. Else exit program.
But as I said, there are many ways to set program registration things.
this is this.
|
|
|
|
|
Hi Khan,
I tried that, but I got a Debug Assertion Failed! It said :" Program c:\Test.exe File afxwin1.inl Line 22, as soon as the code executes the line "CFileDialog fd(TRUE)". I guess I must have some thing wrong with my project setting. Any idea?
Thank
Jim
|
|
|
|
|
|
Hi,
I have used this as suggested by Khan:
CFileDialog fd(TRUE);
int nResult = fd.DoModal();
if (nResult == IDOK)
{
CString strPath = fd.GetPathName();
}
as soon as it hits the line CFileDialog fd(TRUE), then it goes into
CFileDialog::CFileDialog(BOOL bOpenFileDialog,
LPCTSTR lpszDefExt, LPCTSTR lpszFileName, DWORD dwFlags,
LPCTSTR lpszFilter, CWnd* pParentWnd) : CCommonDialog(pParentWnd)
{
memset(&m_ofn, 0, sizeof(m_ofn)); // initialize structure to 0/NULL
m_szFileName[0] = '\0';
m_szFileTitle[0] = '\0';
m_pofnTemp = NULL;
m_bOpenFileDialog = bOpenFileDialog;
m_nIDHelp = bOpenFileDialog ? AFX_IDD_FILEOPEN : AFX_IDD_FILESAVE;
m_ofn.lStructSize = sizeof(m_ofn);
m_ofn.lpstrFile = m_szFileName;
m_ofn.nMaxFile = _countof(m_szFileName);
m_ofn.lpstrDefExt = lpszDefExt;
m_ofn.lpstrFileTitle = (LPTSTR)m_szFileTitle;
m_ofn.nMaxFileTitle = _countof(m_szFileTitle);
m_ofn.Flags |= dwFlags | OFN_ENABLEHOOK | OFN_ENABLESIZING;
if (!afxData.bWin4 && AfxHelpEnabled())
m_ofn.Flags |= OFN_SHOWHELP;
if (afxData.bWin4)
{
m_ofn.Flags |= OFN_EXPLORER;
--> problem here m_ofn.hInstance = AfxGetResourceHandle();
}
m_ofn.lpfnHook = (COMMDLGPROC)_AfxCommDlgProc;
The problem is in m_ofn.hInstance = AfxGetResourceHandle();
// Global helper functions
_AFXWIN_INLINE CWinApp* AFXAPI AfxGetApp()
{ return afxCurrentWinApp; }
_AFXWIN_INLINE HINSTANCE AFXAPI AfxGetInstanceHandle()
{ ASSERT(afxCurrentInstanceHandle != NULL);
return afxCurrentInstanceHandle; }
/* problem in the following Aserttion */
_AFXWIN_INLINE HINSTANCE AFXAPI AfxGetResourceHandle()
--->>>> { ASSERT(afxCurrentResourceHandle != NULL); <<<<<<<---------PROBLEM
return afxCurrentResourceHandle; }
_AFXWIN_INLINE void AFXAPI AfxSetResourceHandle(HINSTANCE hInstResource)
{ ASSERT(hInstResource != NULL); afxCurrentResourceHandle = hInstResource; }
_AFXWIN_INLINE LPCTSTR AFXAPI AfxGetAppName()
{ ASSERT(afxCurrentAppName != NULL); return afxCurrentAppName; }
_AFXWIN_INLINE COleMessageFilter* AFXAPI AfxOleGetMessageFilter()
{ ASSERT_VALID(AfxGetThread()); return AfxGetThread()->m_pMessageFilter; }
_AFXWIN_INLINE CWnd* AFXAPI AfxGetMainWnd()
{ CWinThread* pThread = AfxGetThread();
return pThread != NULL ? pThread->GetMainWnd() : NULL; }
Jim
|
|
|
|
|
Hi...sorry but I'm poor English..
I want make Dialog Box without its class.
Nice Days...
void CMExOdbcView::OnModedata()
{
CDialog* pDlg = new (*((CDialog*) GetDlgItem(IDD_EDIT_DLG)));
if(pDlg->DoModal() == IDOK)
{
m_pSet->m_name.Format("%s", GetDlgItemText(IDC_EDIT_NAME));
m_pSet->m_address.Format("%s", GetDlgItemText(IDC_EDIT_ADDRESS));
m_pSet->m_tel.Format("%s", GetDlgItemText(IDC_EDIT_TEL));
m_pSet->m_bigo.Format("%s", GetDlgItemText(IDC_EDIT_BIGO));
m_pSet->Update();
}
}
|
|
|
|
|
when you enter the if(...== IDOK), the dialog box has already been destroyed.
So you can't use the GetDlgItemText(...) over there. You got to subclass and store in member variables of the class and you should access the member variables of the pDlg object after it comes out.
|
|
|
|
|
I create a 1 column, 2 row splitter window. use CreateStatic, because I want too different view in each panes. But I also want dynamically delete a pane, how to do this?
Thank u.

|
|
|
|
|
Hi,
I have a nested structure FREQ_ANAL, I want to return this structure from a VC++ DLL to a VB client. What is the best way to do that?
typedef struct FrequencyData
{
DWORD specData[FRMBUFF][FFTSIZE];
DWORD timeVal[FRMBUFF][FFTSIZE];
}FREQ_DATA;
typedef struct FrequencyAnalysis
{
FREQ_DATA freqData;
int result;
}FREQ_ANAL;
Thanks, Ratna
|
|
|
|
|
I'm no VB expert (I've used it a little) but I the way I'd proceed is to wrap the data structure with a COM object.
Steve
|
|
|
|
|
You need to create a SafeArray. There are probably some examples here on CodeProject ...
Phil
|
|
|
|
|
In MDI project. I want my child frame fill main frame window. So I inplement this in
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs
CWnd* pwnd = AfxGetMainWnd();
CRect rect;
pwnd->GetClientRect( &rect );
cs.cx = rect.Width(); cs.cy = rect.Height();
if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE;
return TRUE;
}
It's very close to success. But look closely, you will find a bit off. main frame overlapped child frame a little bit. I think that is because of edge of main frame window. But I am getting client area, it should not include edge right? any one can explain?

|
|
|
|
|
|
Many people recommend using member Get/Set functions in order to access class data, with the data members themselves being private/protected . I am pretty much sold on the idea, and though it means it takes longer to knock together even a basic class, the benefits are worth the effort IMHO.
However, I also make use of STL containers in my classes, but I have yet to find a satisfying way in which I should allow access to a private container. I have seen many classes that simply return a reference to the container, e.g.:
class CFoo
{
private:
std::list<std::wstring> m_strings;
public:
inline std::list<std::wstring>& GetStrings(void) { return m_strings; }
};
I'm sure you'll agree that this is pretty useless - you may as well make the container public and be done with it (OK, you can change the name of the container without having to change code that uses it, but this is still fairly insignificant).
So, how do others here offer access to such containers (doesn't have to be an STL container - could be an MFC/ATL CList/CArray/etc. )?
Take an example - I have a class that enumerates installed printers and stores the name of each printer in a std::vector . Now, if I wanted to fill a listbox with these printer names, I *could* offer a class method to do this for me, and thus hide the internal container implementation from the caller. However, in reality, I might also want the list of printers in a listbox, or a list control, or as text in an edit, etc. etc. so allowing calling code access to the vector is essential. How would you go about this while adhering to the Get/Set methodology?
One thought - for STL containers - would be to return const iterators, e.g.:
class CFoo
{
private:
std::list<std::wstring> m_strings;
public:
inline std::list<std::wstring>::const_iterator begin() const { return m_strings.begin(); }
inline std::list<std::wstring>::const_iterator end() const { return m_strings.end(); }
};
...
CFoo foo;
for (std::list<std::wstring>::const_iterator it = foo.begin(); it != foo.end(); ++it)
{
}
Thoughts?
The Rob Blog Google Talk: robert.caldecott
|
|
|
|