|
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
|
|
|
|
|
The idea of getter and setter method is that it let the programmer hide the implementation of the data ( decoupling ).
when dealing with containers, I would create an iterator (non STL ) class over that container, so that I can eventually change the container type without having to change every client accessing that class.
in your example, the user need to know that you are using an STL list, he does'nt need to know that, only to get a printer in that class.
I'm sorry I don't have a definitive solution for you; but it's a good question.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hello,
As some other user suggested, creating another iterator over the container is the ideal solution. You can change the container and nobody has to know it.
If you don't mind that the class exposes the data structure (container), you can override the index operator: operator[](int nIndex) to make life simple and easy.
I also suggest that you hide the STL completely from your class to make it more reusable and hide implementation details from users. I assume that you use the std::wstring as return values and such. It's better to return const wchar_t* instead of a string class. This way, you don't foce your users to use STL or an other library.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
CDC dc;
CPrintDialog pdlg(FALSE,PD_NOPAGENUMS|PD_NOSELECTION,this);
BOOL bFindPrinter=pdlg.GetDefaults();
//////////////////////////////////////////////
//using the following code,I want to stop the 24-Pin Dot Matrix Printer at the 100mm length.But something is wrong ,it doesn't work.
DEVMODE* lpDevMode = NULL;
lpDevMode = (DEVMODE*)::GlobalLock(pdlg.m_pd.hDevMode);
lpDevMode->dmFields |= DM_PAPERSIZE;
lpDevMode->dmFields |= DM_PAPERLENGTH;
lpDevMode->dmFields |= DM_PAPERWIDTH;
lpDevMode->dmPaperSize = DMPAPER_USER;
lpDevMode->dmPaperLength = 100;
lpDevMode->dmPaperWidth = 100;
::GlobalUnlock(pdlg.m_pd.hDevMode);
/////////////////////////////////////////////////////
dc.Attach(pdlg.GetPrinterDC());
CFont font;
VERIFY(font.CreatePointFont(120, "System", &dc));
CFont* def_font = dc.SelectObject(&font);
int nPageHeight, nPageWidth;
nPageHeight = dc.GetDeviceCaps(VERTRES);
nPageWidth = dc.GetDeviceCaps(HORZRES);
TEXTMETRIC TextM;
dc.GetTextMetrics(&TextM);
int nCharHeight = (unsigned short)TextM.tmHeight;
int nCharWidth=(unsigned short)TextM.tmAveCharWidth;
DOCINFO di;
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = "FarFly printing";
di.lpszOutput = (LPTSTR) NULL;
di.lpszDatatype = (LPTSTR) NULL;
di.fwType = 0;
dc.StartDoc(&di);
dc.StartPage();
int line = 0;
CString s = "My Test String";
dc.TextOut(2,line++,s,strlen(s));
dc.EndPage();
dc.EndDoc();
dc.SelectObject(def_font);font.DeleteObject();
DeleteDC(dc.Detach());
thanks for your help...
|
|
|
|
|
yujia120 wrote:
lpDevMode->dmPaperLength = 100;
lpDevMode->dmPaperWidth = 100;
dmPaperLength and dmPaperWidth are in tenths of a millimetre.
Phil
|
|
|
|
|
Thank Phil ,i modified them as the following:
lpDevMode->dmPaperLength = 1000;
lpDevMode->dmPaperWidth = 1000;
but the printer doesn't stop at the 100mm-length line.
How does 'Word 2003' implement the function?
it can define the paper length and width,and the printer can stop when running at the length line.
|
|
|
|