|
Define USES_CONVERSION; at the top of the method implementation you are trying to do the conversion in. then use W2T
void foo(BSTR bstrVariable)
{
USES_CONVERSION;
// conversion is done to the stack so don't delete on function exit
// and don't use pointer outside of method.
LPCTSTR pcstrVariable = W2T(bstrVariable);
// TODO: do work with string.
}
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
Can any one please provide me with a way to enable the inserting of tabs into a RichEdit control within a dialog based application. The rich edit control is contained within a tab control page therefore the normal action when the tab key is pressed is to tab to the next tab in the control.
|
|
|
|
|
Is there a function that can convert a CString containing a hexadecimal or octal string to an integer. atoi() only works for decimal strings.
---
Multitasking: Screwing up several things at once.
|
|
|
|
|
|
|
Hi,
I have a MDI application, and I can display bitmaps and draw lines..
Lets say that I do everything that I wanna do on the first document.
I like to use to same data( lines, points) on my next document..
how can i do that?
Thanks
Ehsan Behboudi
|
|
|
|
|
Here is a way of iterating through your open documents:
CWinApp* pApp = AfxGetApp();
POSITION posTemplate = pApp->GetFirstDocTemplatePosition();
while (posTemplate)
{
CDocTemplate* pTemplate = pApp->GetNextDocTemplate(posTemplate);
POSITION posDocument = pTemplate->GetFirstDocPosition();
while(posDocument)
{
CDocument* pDoc = pTemplate->GetNextDoc(posDocument);
if (pDoc)
{
Having done so, there is no reason you'd have any problems copying data from one document to another.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
thanks for your reply,,
I like to know,if this is a way of only copying data from an open document to another,
or having access to the open document's data,, or both??
In my application i need to have access to the data too.
another question:
Does this mean that I have to use serialization method in my application?
thanks
Ehsan Behboudi
|
|
|
|
|
If you have the pointer to the document, then you have access to the data ( or at least get methods ). You can use GetActiveDocument() to get a pointer to the current active document, use the code I gave you before to get access to another document, and then copy between them.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
I know that the Submit and Preview buttons don't look the same but I still managed to hit the wrong one. Will try again with the question.
OK, I am still working on my ground breaking Dialog based database application. Answers to my previous questions have allowed me to get things working the way I wanted but as always I have found another annoyance I can't work around.
In the summary screen for say Customers I fill the ListCtrl with data returned by a
SELECT *
FROM
CUSTOMERS
of course this means that the first column contains the Primary Key which I don't need the user to see. I could select each column except the Primary Key individually to fix this but this leads me to another problem. When a user selects a row to Delete a Customer I use the value in the first column as the key to delete the correct record.
So what I want is to Hide the first column containing the key so the user can't see it but still have it returned by GetItemText when I need the key to Delete or Update.
Can this be done?
Can some kind developer give me the function?
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
Are the customer names unique ? If so, you could build a map to hold the key. Maps rule.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
You can do this by the clistctrl function - setitemdata();
instead of insertcolumn
example:
m_lst.setitemdata(0,/*the unique customer id*/);
|
|
|
|
|
You can always set the Primary Key column's width to 0, thereby making it hidden.
LVCOLUMN lvColumn;
memset(&lvColumn, 0, sizeof(lvColumn));
lvColumn.mask = LVCF_WIDTH;
listCtrl.GetColumn(0, &lvColumn);
lvColumn.cx = 0;
listCtrl.SetColumn(0, &lvColumn);
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
OK, I am still working on my ground breaking Dialog based database application. Answers to my previous questions have allowed me to get things working the way I wanted but as always I have found another annoyance I can't work around.
In the summary screen for say Customers I fill the ListCtrl with data returned by a
SELECT *
FROM
CUSTOMERS
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
Ignore this question due to blatant stupidity I stuffed up and hit the wrong button. Question reposted above.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
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!
|
|
|
|