|
FYI. You can delete your posts using the [Delete] link found at the bottom right corner of every posting.
---
Multitasking: Screwing up several things at once.
|
|
|
|
|
Hi,
I'm converting some old vb code to a VC++ application and there is this function called ScaleX which converts a coordinate from twips to pixels. Is there any equivalent function in VC++?
Thanks for any help you can provide,
Craig
|
|
|
|
|
You can do this using two different methods:
1) set the mapping mode of device context to MM_TWIPS, then call DPtoLP.
2) perform calculations 'manually' using value returned from GetDeviceCaps(hdc, LOGPIXELSX) - it's a number of pixels per 'logical inch'.
int logpixx = GetDeviceCaps(hdc, LOGPIXELSX);
int pix = logpixx * twips / 1440;
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hello,
Is it possible to get a process's PID if the name of the application is known? Is there a function such as "GetProcessIdByName", or is there some alternative hack? BTW, I am developing with Visual Studio 6 for Windows NT/2000, and using the July 2000 Platform SDK.
Thanks for any help,
Jon Sagara
|
|
|
|
|
Another user's question actually answered mine. For those who are interested, please see the following MSDN article:
http://support.microsoft.com/support/kb/articles/Q175/0/30.ASP
Thanks,
Jon Sagara
"When I was fourteen, I was amazed at how unintelligent my father was. By the time I turned twenty-one, I was astounded how much he had learned in the past seven years." -- Mark Twain
|
|
|
|
|
I need to open a file from one function then manipulate it in another. How do I pass the stream to the second function.
I am using the fstream header file for I/O..
|
|
|
|
|
Try passing the stream object by reference.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
I thought that was all I had to do. I must be doing something wrong with syntax or something... Here's the jist of what I am doing....
#include <fstream.h>
void ReadFile(ifstream &stream);
int main()
{
ifstream in;
in.open(FileName);
ReadFile(in);
}
ReadFile(ifstream &stream)
{
}
I get compiler errors n'stuff. I'm not passing the stream object correctly I believe...
|
|
|
|
|
I think you problem is that;
a) you need to include both <iostream> and <fstream>
b) you need to bring the classes declared in the std namespace into scope.
I re-wrote it to do all of this;
#include <iostream>
#include <fstream>
using namespace std;
void ReadFile ( ifstream & stream );
int main () {
ifstream fin;
fin.open ( theFileName );
ReadFile ( fin );
}
void ReadFile ( ifstream & stream ) {
}
That should do it for you.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Hi, I am a new to C++ MFC design so thanks in advance for the inputs.
I am wondering if anyone can tell me where is the best place to put the SetRange(int, int) command for a spinner inside a modeless propertyPage. I understand the usual place is in OnInitDlg. However, I don't think there is a similar OnInit function for my property page/sheet.
Thanks!
|
|
|
|
|
OnInitDialog is OK, assuming that range remains the same during the lifetime of your object.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Yes, I would put SetRange in OnInitDialog too in a heart beat, but CPropertySheet class does not have the OnInitDialog function for me to inherit like in CDialog... so I'm lost for ways there.
|
|
|
|
|
Just use this:
BOOL CYourPage::OnInitDialog()
{
CPropertyPage::OnInitDialog();
return TRUE;
}
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hmm.. there is no OnInitDialog() fcn in CPropertyPage or any of its parents. This exactly what I am stuck on. I know I can initialize my SetRange in OnInitDialog if I had a dialog, but I don't I have a CPropertyPage.
btw, the tree for these classes is:
. . . . . . . . . . . . . . . . . . . . . . . .-> CDialog . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . / . . . . . . . . . . .
CObject -> CCmdTarget -> CWnd -<. . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . \ . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .-> CPropertySheet. . .
So there's no OnInitDialog for CPropertySheet.
|
|
|
|
|
CPropertyPage derives from CDialog - your tree is not based on facts . If you insert CPropertySheet::OnInitDialog() into CYourPage::OnInitDialog, the CDialog::OnInitDialog will be called.
Anyway, if you don't want to use OnInitDialog, use OnSetActive or DoDataExchange instead.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Ah, yes you are correct! I was looking into the wrong place -- the CPropertySheet, instead of CPropertyPage. Thanks! My spinner works like a charm now
|
|
|
|
|
I intend to add a CEdit box to the main window (a drawing program which is NOT Dialog based) so I can always show the x,y coordinates in that box. I've added such a variable to the View class and created it in the constructor, but it does not appear in the main window, how can I make it display?
|
|
|
|
|
You have to create the edit control in your view's OnCreate() handler.
int CTestView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
m_myEdit.Create(WS_VISIBLE|WS_CHILD|WS_BORDER, CRect(10,20,30,40), this, ID_MYEDIT);
return 0;
}
---
Multitasking: Screwing up several things at once.
|
|
|
|
|
Thanks. I've successfully added it. I also added a combobox on the window, which dynamically contain some string. What I want is that when make a choice in the combobox, the code will do different things, how can I do that? It's simple in Dialog based program, but I have no idea how to do that in non-Dialog-based.
|
|
|
|
|
You do it exactly the same way as in a dialog. You just have to do it manually, classwizard will not help you. Add your message map entries and member functions.
BEGIN_MESSAGE_MAP(CTestView, CView)
ON_WM_CREATE()
ON_CONTROL(CBN_SELCHANGE, ID_MYCOMBO, OnSelChanged)
END_MESSAGE_MAP()
void CTestView::OnSelChanged()
{
DoSomethingWhenSelectionChanges();
}
---
Multitasking: Screwing up several things at once.
|
|
|
|
|
I tried but it does not work. I also tried to change ON_CONTROL to ON_NOTIFY, it does not work either. The function, say CTestView::OnSelChanged() should be declared with type "afx_msg", right? Is there any other trick besides what you said above? By the way, my application is a windows CE program, could this be the reason?
|
|
|
|
|
|
There is a WIN32 function GetFileVersionInfo to get file version information. Is there a "SetFileVersionInfo" or similiar WIN32 function to change the version information?
|
|
|
|
|
There is a WIN32 function GetFileVersionInfo to get file version information. Is there a "SetFileVersionInfo" or similiar WIN32 function to change the version information?
|
|
|
|
|
Up to my knowledge, this information is stored in the DLL as a resource! So you can change it at design time from within your compiler! What do you mean changing the value at runtime? In memory only or do you want the chage to be permenant?!
|
|
|
|