|
Well yes but the wierd thing is that the text gets cut off like half of it at least...
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
CMyDialog is a modal dialog invoked in CMyView, in CMyDialog, user can temporarily hide the dialog and go to CMyView window and use mouse to pick a point, then return to the dialog.
But how to implement the function gPickPoint() below,
CPoint gPickPoint()
{
CPoint pt;
// wait? loop? until user pick a point
return pt;
}
CMyView::OnBtnMyDialog()
{
CMyDialog dlg(this);
dlg.DoModal();
}
CMyDialog::OnBtnPickPoint()
{
CPoint pt;
CWnd *pFrameWnd = GetParent();
// hide dialog and go to view window
pFrameWnd->EnableWindow(TRUE);
ShowWindow(SW_HIDE);
pFrameWnd->SetFocus();
// waiting for user to pick a point from view
pt = gPickPoint();
// return from view window to dialog
ShowWindow(SW_SHOW);
SetFocus();
pFrameWnd->EnableWindow(FALSE);
EnableWindow(TRUE);
}
|
|
|
|
|
For the point-click handling, here's the design routine:
1. Use GetClienRect or GetWindowRect to get the view window's dimensions into a RECT structure. If using GetClientRect , remember to convert into screen coordinates.
2. Use ClipCursor to restrict the cursor into moving inside the defined RECT only. The cursor cannot leave this area now. Also, set a flag e.g. m_bCursorIsClipped to TRUE.
3. In the WM_LBUTTONDOWN handler of the view, check the flag value, and if it says that the cursor is clipped, then first send the point information to the dialog, then remove the clipping rectangle and show the dialog window again, hiding the main view. Lastly, set the flag to FALSE.
The clipping rectangle ensures that the user cannot do anything else on the frame window. He can use ALT+TAB to switch to other programs: in this case, you must handle this request (WM_KILLFOCUS ) and remove the clipping rectangle if it exists. You can re-set the clip in WM_SETFOCUS handler, if needed.
You should code a new user message for the view, called WM_USER_PICKPOINT , for example. Then in the dialog's button click handler, issue this message to the view window after hiding the dialog and showing the main frame. The handler for this message in the view window sets the cursor clipping region and the flag. The clipping region is removed and the flag nullified in the WM_LBUTTONDOWN handler of the view window, like I explained above.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Yes, it works.
Instead of restrict mouse within view's client area, I put patches for many toolbar or menu commands, and WM_CLOSE for main frame, to prevent user from running other command before this cmd finished.
But another little problem appears, CWinApp::OnIdle() ceased, which means ON_UPDATE_COMMAND_UI disabled. not sure why.
|
|
|
|
|
Hello,
How can I get the file size of a file using standard C++ library (not MFC)?
Thanks!!
Nachi
|
|
|
|
|
Do you mean, a function like _filelength ?
|
|
|
|
|
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
fstream file;
int size = 0;
file.open("test.txt",ios::in); //Replace test.txt with file name
if(file.is_open())
{
file.seekp(0,ios::end); //Move position of stream to the end
size = file.tellp(); //Get position at end which tells size
file.close();
}
cout << "File size: " << size << endl;
return 0;
}
|
|
|
|
|
Hello!
GetFileSize() is WinAPI
|
|
|
|
|
My Access DB uses DD/MM/YYYY as do my text fields, but when I populate the list control (based on a code project sample) I get the format YYYY-MM-DD.
The offending line from FillData is
rgData = (LPSTR)rs->m_ppvData[nField];
Is there a directive I can give to OBDC to feed dates in as DD/MM/YYYY or should I be interpreting the contents of rgData?
Ger
|
|
|
|
|
You should not be assuming the date is in *any* format. A date is a date is a date, regardless of what format it is displayed in. If Access wants to display dates in DD/MM/YYYY format, fine. If you want to display dates in YYYY-MM-DD format, fine. For consistency, use the locale settings.
Ger Hayden wrote:
...but when I populate the list control (based on a code project sample) I get the format YYYY-MM-DD.
Check the Regional Settings applet in Control Panel.
Ger Hayden wrote:
The offending line from FillData is
rgData = (LPSTR)rs->m_ppvData[nField];
Which is meaningless since you have not provided the type of rgData , rs , m_ppvData , or nField .
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Thanks David, Regional Settings are as specified in your reply. When I return to a proper modem line, I will elaborate more - am currenly on a mobile phone at 14.4bps so one must be brief
Ger
|
|
|
|
|
ded·i·ca·tion
n.
1. Catching up on CP posts using a mobile phone!
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Thanks for the tips David. I side stepped the issue by trapping the column in a dedicated 'FillData' routine and re formatted them as required. However I now have an issue getting a ColeDateTime field to communicate with an ACCESS Date/Time field. I may well change the access field to an integer and use the .dt repesentation of the ColeDateTime field to interface.
Ger
|
|
|
|
|
I have a TV tuner with a crappy app that controls it and no scheduler to record shows. I would write my own app to schedule the startup of the crappy app and the ALT-R to begin record and again to stop it.
Unfortunately all I know is that I have to send the app a certain message. Any clues guys?
Thank you,
Andrei.
LATER UPDATE:
So I found you can use:
PostMessage(hwnd, WM_CHAR, WPARAM('^'), LPARAM(M)); for CTRL-M
But there appears 2 more questions in my mind:
a) How do you do it for ALT-R or ALT-F4? Any general rule?
b) How do you determine the handle of the window you want to send it to? Mine has "PCTV Vision" in the title. Any chance you have to use FindWindow?
TNX!
|
|
|
|
|
I like using Spy++ (part of the Visual Studio suite). It has several input methods - type the dialog name, 0x handle number, or select a cross-hair pointer and zap the window you want info on.
Johnny
|
|
|
|
|
For your b) question, here's how:
HWND hwnd = ::FindWindow(NULL,"PCTV Vision");
Then you can call PostMessage using hwnd
For alt+f4, you could just use ::PostQuitMessage(0);
I am not sure at all on how to send (i.e: CTRL+M), but if PostMessage(hwnd, WM_CHAR, WPARAM('^'), LPARAM(M)); works, then PostMessage(hwnd, WM_CHAR, WPARAM('!'), LPARAM(R)); would do the job.
One more thing. If you are coding an MFC application, you will need to add ' :: ' in front of your PostMessage's and FindWindow's, since you want to play with HWND values, and not CWnd
Michael
|
|
|
|
|
Where do I start? I'm sure there's some interface or class that does the job...!
Thanks!
---------------
Tired of Spam? InboxShield for Microsoft® Outlook® 2K/2K2/2K3
http://www.inboxshield.com
|
|
|
|
|
(Extended) MAPI, SMTP, and CDO are good places to start.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Are you trying to make a virus, kinda like the one which broke out and literally slowed down the internet, do you believe, THE INTERNET but no it was reworded incorrectly, they probably meant were gonna sue the ass off of the person responsible for this cause we couldn't spam anyone out ... The email servers...
Extra! Extra!
http://www.cnn.com/2004/TECH/internet/01/27/mydoom.spread/index.html[^]
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
i'm totally lost on this.
How can I access variables from each page at the CPropertySheet level?
I have a modeless CPropertySheet running with 4 pages contained within - all pages really simple.
I have created my own "Save" and "GO" buttons that exist on the CPropertySheet. "Save" is supposed to collect all the values from the pages and fill a class structure visible at CPropertySheet level. "GO" calls save and then performs a function using the values saved in the class structure.
Any Help?
Johnny
Here is a snap-shot of my declarations (abbreviated for space)
class CFilePageDlg : public CPropertyPage
{
public:
bool UpdatePageData(bool bFromPage);
bool GetInputPathname(CString* szPathname); // tried w/o * also
private:
CString m_szInputPathname;
// other class stuff
}
class CConfigPropSheet : public CPropertySheet
{
public:
CFilePageDlg m_FilePage; // page 1
protected:
//{{AFX_MSG(CConfigPropSheet)
afx_msg void OnSaveConfigSettings();
afx_msg void OnGO();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
CButton m_btnGo;
CButton m_btnSave;
};
// sample functions
bool CFilePageDlg::UpdatePageData(bool bFromPage)
{
CString szTemp;
if (bFromPage)
{
UpdateData(TRUE); // update variables from controls
m_editFileInputFilename.GetWindowText(m_szInputPathname);
}
return true;
}
void CConfigPropSheet::OnSaveConfigSettings()
{
CString szTemp;
m_FilePage.UpdatePageData(TRUE);
m_FilePage.GetInputPathname(&szTemp);
}
|
|
|
|
|
When the OK button is clicked, only those pages that were actually created will have valid/changed data on them. Therefore, you should override the OnOK() method in each page's class and do any saving (e.g., file, data structure) from there.
When does CConfigPropSheet::OnSaveConfigSettings() get called. m_FilePage.UpdatePageData(TRUE) relies upon the m_FilePage window to still exist.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Ok, I made the individual page member variables Public and then just accessed directly at the CPropertySheet level -- all worked! but why?
Johnny
class CFilePageDlg
{
Public:
CString m_szInputPathname;
};
void CConfigPropSheet::OnSaveConfigSettings()
{
MessageBox( m_FilePage.m_szInputPathname, "File Page Var", MB_OK );
}
// I also tried making the page's vars STATIC, but
|
|
|
|
|
Hey, folks.
All I wanted to do was...
I have a property page on a wizard, standard login with two edit controls, username and password. We default the username in some cases. The desired behavior is to set focus to the password if the username has text. Since we're in wizard mode, the user can back / next and hit this page multiple times, so calling SetFocus to the password field in OnInitDialog() would be insufficient.
So, naturally, I put it in OnSetActive(). Focus gets reset to username sometime after this function returns. Tried putting SetFocus in OnActivate(). Same results. Grepped the MFC code looking for SetFocus / SetCurSel calls. No dice. Burned incense. Sacrificed chickens. Still, the username (the first field in tab order), gets focus & text is highlighted whenever this page is displayed.
Anyone here fought this battle before? I'm running out of chickens, and nobody here likes my cooking anyway...
Thanks -
Christopher Duncan
Today's Corporate Battle Tactic
Unite the Tribes: Ending Turf Wars for Career and Business Success
The Career Programmer: Guerilla Tactics for an Imperfect World
|
|
|
|
|
Christopher Duncan wrote:
so calling SetFocus to the password field in OnInitDialog() would be insufficient
Hmm.. I think the return value of OnInitDialog() affects which control gets focus. If you create an ordinary dialog and override OnInitDialog(), the following code is emitted in the function body:
return TRUE;
Have you tried returning FALSE?
--
Try walking in my shoes. You stumble in my footsteps.
|
|
|
|
|
Hey, Jörgen.
Jörgen Sigvardsson wrote:
Hmm.. I think the return value of OnInitDialog() affects which control gets focus.
Problem is, since this is a wizard, OnInitDialog does not get called every time the user navigates to this page. It's called only once, when the page is created. Typically, that's what OnSetActive is used for, but in this case even that doesn't work.
However, I think I'll try returning FALSE when I get to the office tomorrow just for the heck of it. Heaven knows I'm running out of ideas here, short of some really ugly hacks...
Thanks, man.
Christopher Duncan
Today's Corporate Battle Tactic
Unite the Tribes: Ending Turf Wars for Career and Business Success
The Career Programmer: Guerilla Tactics for an Imperfect World
|
|
|
|