|
Try:
typedef struct _mystruct
{
int no;
char str[10];
}pstruct[10];
for(i = 0; i < 5; i++)
{
pstruct[i].no = i;
strcpy(pstruct[i].str, tmpstr);
}
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
pstruct ps[10];
not global scope
|
|
|
|
|
Where can i find documentation on _bstr_t.
I read a blob of data into a _bstr_t and i need to parse this. Have no access to CString as this is in a win32 dll. I need to be able to do a find on this data to get to a certain point and then extract certain key pieces of data from it.
Can anyone help me find decent documentation and even examples on this ?
|
|
|
|
|
MSDN[^] is usually pretty good.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
I tried MSDN ...
I did not get enough examples there....nor was the parsing methods very clear to me....
Any other suggetsions... Or does anyone know how to find a substring in a BSTR?
|
|
|
|
|
Have you looked here[^]? Lots of articles on parsing strings.
This[^] article may be a special help to you.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
The _bstr_t source code is on your PC, but in essence, you should use std::string, or failing that, C stype string mashing with the char * that _bstr_t provides.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello,
I have a CComboBox with three items in a dialog-based application. When I click on the combobox, the drop-down list only shows one item at a time and gives me a scrollbar. I want the drop-down list to show all three items.
I must be missing something. This must be a simple thing but I can't figure it out.
Thanks!
-Ian
|
|
|
|
|
in the resource editor, click on the "down arrow", an expended view of the combo box will be displayed, you can drag the bottom edge to make the dropped part bigger.
I normally give it a big size to at least 15 items are visible.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Ah ha! Yes! thank you. That was driving me nuts!
-Ian
|
|
|
|
|
In your resorce view you have to hold the left mouse click down on the combo box and extend it. This should show all your items in the list.
Hope this helps...
|
|
|
|
|
Thanks! (you do have to click the down-arrow on the combobox first. I would never have figured that out on my own.)
-Ian
|
|
|
|
|
See here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Thanks Jack Squirrel!
My problem now is to transfer an array of double from the 'Doc to the 'View. I can make the transfer via a CArray of CString 's, which would be ok but messy. When I say 'transfer' I mean read the contents of doubles filled and working nicely in 'Doc into 'View. Clicking them all across with the mouse is not on the agenda. Thanks.
Zeitweise wissen wir nicht was wir wissen.
|
|
|
|
|
E Dyot wrote:
My problem now is to transfer an array of double from the 'Doc to the 'View.
So you have something like:
class CMyDocument : public CDocument
{
public:
double m_arrNumbers[5];
};
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
If you have declared the array as a member of the CMyDocument then you can do this in your CMyView class(in the function that needs the array)
... CMyView::function name(...)
{
CMyDocument *doc = GetDocument();
.....
doc->m_arrNumbers[x] = ....;
}
|
|
|
|
|
Ok, no kidding. I simply want to create a an xml file with the following content.
?xml version="1.0" encoding="UTF-8" ?
Form xmlns="urn:query" Sender="G" Software="Me"
AutoSend>Yes
ResponseKey PrintResponse="No" TwoWayXML="Yes">xvpqr7
FormName>RQ
Operator>
OperatorName>test
Password encryption="Cipher">000000000000
/Operator>
Fields>
Field>
FieldName>DRI
Value>GA
/Field>
Field>
FieldName>LIC
Value>ABC123
/Field>
Field>
FieldName>LIT
Value />
/Field>
Field>
FieldName>VMA
Value />
/Field>
/Fields>
/Form>
I am using the createNode function to create the nodes, however, after each node creation, i am appending and releasing.
This does not seem to work when it comes to my second node that i am appending.
_variant_t varTyp((short)MSXML2::NODE_ELEMENT);
HRESULT hr;
CoInitialize(NULL);
hr = pXMLDom. CreateInstance(__uuidof(DOMDocument40));
//Preserve whitespace
pXMLDom->preserveWhiteSpace = VARIANT_TRUE;
//Create Processing Instruction
pi = pXMLDom->createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
if (pi != NULL)
{
pXMLDom->appendChild(pi);
pi.Release();
}
//Create Node and append to Document
pNode=pXMLDom->createNode(varTyp,"Form","urn:query");
// Set pNode to a valid reference of some node
// Now cast it to IXMLDOMElement
pNode->QueryInterface(IID_IXMLDOMElement, (void**)&pDOMElement);
// Now use "pDOMElement" to add an attribte
pDOMElement->setAttribute("Sender","10");
pDOMElement->setAttribute("Software","Mine");
//Append to DOM Document
pXMLDom->appendChild(pNode);
//Release Node and element
pNode.Release();
pDOMElement.Release();
*****Here is where when i try to append again i get a com error on the appendChild call.
//Create AutoSend Node
if (SUCCEEDED(pNode=pXMLDom->createTextNode("AutoSend")));
if (SUCCEEDED(pNode->put_text (BSTR(L"Yes"))));
//Append to DOM Document
if (SUCCEEDED(pXMLDom->appendChild(pNode)));
//Release Node
pNode.Release();
Can anyone tell me what i am doing wrong or guide me to an example that would do nested nodes and attributes like the one that i am attempting to do..
Thanks,
|
|
|
|
|
|
Does anyone have any examples on how to use the readfile() function. This is my first time to use it and I'm taking the instructions straight from MSDN and it's not working. Here is what I have.
HANDLE fptr;
bool bResult;
LPVOID inBuffer;
DWORD nBytesToRead = 20;
LPDWORD nBytesRead = 0;
bResult = ReadFile(fptr, &inBuffer, nBytesToRead, nBytesRead, NULL);
I don't think I fully understand how the function works.
|
|
|
|
|
There are many problems with the code you posted... these parts are OK:
Camron wrote:
HANDLE fptr;
bool bResult;
DWORD nBytesToRead = 20;
But here are the problems...
LPVOID inBuffer;
LPDWORD nBytesRead = 0;
These should be similar to the following:
<br />
UCHAR inBuffer[10000];
DWORD nBytesRead = 0;
Now with those changes, there is one more step before you can read...
fptr is a handle to a file - you haven't opened a file yet!
Now your attempt to read would become:
bResult = ReadFile(fptr, inBuffer, nBytesToRead, &nBytesRead, NULL);
After you read, you can close the file.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
<kmedcalf@ev1.net>
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Hello. I'm reading and excel (.xls) file using ODBC. For the most part it's working well, except I have a few columns that aren't being read accurately. The problem columns have data that can be either an int, text, or range such as int-int (ie. 12-16). The columns are specified as a general number format, although I have tried to change them to text.
The problem is that the results from the query are not reading all the data formats. So in a columns described above, it may only read int values, but not the range value. When it queries a cell with the range data the result is empty.
It seems that whatever type of value is first in the column defines which data type will be able to be read from the column. So if the first value in the column in a range (12-15), then only ranges will be accurately read, while int's will not.
Is this a probem with the database being setup incorrectly? Or is there a way to read the data regardless? as a string say?
Any thoughts on how I can fix this problem would be greatly appreciated.
Thanks.
|
|
|
|
|
The problem is in the logic used by the Excel ODBC driver. It treats the spreadsheet as if its rows and columns were rows and columns in a relational database table. As part of this, it assigns a datatype to each column. The problem is, a spreadsheet column may contain mixed datatypes. The ODBC driver makes a best guess at the datatype, based on the first couple of rows of data. Unfortunately, values for any cells that can't be expressed as this datatype instead appear as NULL.
Check out MSDN Knowledge Base Q257819 ("How To Use ADO with Excel Data from Visual Basic or VB"), particularly the section entitled "A Caution about Mixed Data Types".
|
|
|
|
|
does ::GetMetaFile() open the file once its called. what function do i call to close the metafile. Because once i try to open the file later, it gives me a sharing violation error.
thanks
|
|
|
|
|
GetMetaFile() has been superseded by GetEnhMetaFile() . When the handle is no longer needed, call DeleteEnhMetaFile() .
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I have been looking for a utility that would go thru my VC++ MFC project code and delete all unused files. My best guess is I need some kind of reverse compiler.
I have never done any compiler work (build a compiler) and have no clue where to start.
Any ideas?
Thanks for reading
Vaclav
|
|
|
|