|
John R. Shaw wrote: think forgot his original post and toke you seriously.
anyways Happy New year Sir
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
hi, i am new to usage of CListCtrl control. I want 2 display a image column as 1st column of the CListCtrl . I want 2 prevent only this column from being resized.
Cud someone suggest me a way to do the same.
Also is it possible to conditionally hide/show the images on this column?
If possible, cud some1 send a sample code as an illustration.
|
|
|
|
|
|
Hello All,
Not to toot my own horn...well, OK...to toot my own horn
You may recall my step-by-step DCOM tutorial for VC6, which I posted at
http://www.codeproject.com/com/HelloTutorial1.asp[^]
The tutorial isn't meant to reveal the underlying theory and gory detail of DCOM itself, just like the Scribble tutorial wasn't exactly meant to tour every nook and cranny of MFC. However, the tutorial shows each step to take to build a very simple DCOM server and client.
People have been asking me to update the tutorial for VS.NET. And, at last, the new tutorial series is in the midst of being written. Check it out at
Step 1: http://www.codeproject.com/useritems/HelloTutorial1NET.asp[^]
The tutorial is written in several "Steps" -- the main parts of the process. Step 1 is linked above, and each Step contains links to every other step.
Do me a favor, and use the rating at the bottom of each step to score that Step, and post to the Steps' message boards with your questions, and also suggestions on how to make a certain Step better etc. I welcome any and all input, and both positive kudos and constructive feedback together are great. Thanks!
Sincerely Yours,
Brian Hart
Department of Physics and Astronomy
University of California, Irvine
|
|
|
|
|
// CDib operated_dib;
GLOBALHANDLE hGMem ;
OpenClipboard();
hGMem = GetClipboardData(CF_DIB);
operated_dib.GetClipBoard (&hGMem);
int n=10;
int height=operated_dib.GetHeight();
int width=operated_dib.GetWidth();
........
here is the contents of the GetClipBoard (&hGMem),I donn't know where the mistakes are?
BOOL CDib::GetClipBoard(GLOBALHANDLE hGMem)
{
pDib = (BYTE*)GlobalLock(hGMem);
m_pBitmapInfo = (BITMAPINFO*) pDib;
m_pBitmapInfoHeader = (BITMAPINFOHEADER*) pDib;
m_pRGB = (RGBQUAD*)(pDib +
m_pBitmapInfoHeader->biSize);
int m_numberOfColors = GetNumberOfColors();
if (m_pBitmapInfoHeader->biClrUsed == 0)
m_pBitmapInfoHeader->biClrUsed =
m_numberOfColors;
DWORD colorTableSize = m_numberOfColors *
sizeof(RGBQUAD);
m_pData = pDib + m_pBitmapInfoHeader->biSize
+ colorTableSize;
if (m_pRGB == (RGBQUAD*)m_pData) // No color table
m_pRGB = NULL;
m_pBitmapInfoHeader->biSizeImage = GetSize();
m_valid = TRUE;
m_width=GetWidth();
m_height=GetHeight();
return m_valid;
}
|
|
|
|
|
greenapplezlp wrote: I donn't find the mistakes!
What Errors did u get??
|
|
|
|
|
Compiling and executeing the program are successful! but when I add the program above, Compiling is successful while executeing is wrong.It emerges a dialog box,which contents are as following--RobotVideo.exe 遇到问题需要关闭。我们对此引起的不便表示抱歉......
|
|
|
|
|
I dont know what your error message is, but it looks like you doing a lot of castin....be sure that the casts are valid and that any objects you cast inherit from the object you are casting to somewhere
Pablo
|
|
|
|
|
thank you for your enthusiastic help!
|
|
|
|
|
Hi All,
I am building an application using directshow to play mp3 and streaming files (e.g. asx format). It work fine when playing mp3, but it always prompt the error message "The source filter for this file could not be loaded." while I can play the link in WMP ..... Would anyone help to provide some possible solution?
Thanks a lot!
|
|
|
|
|
Could someone please give a novice a hand? class data { CString name; CString Address; CString age;};
vector<data> mydata. This will hold data I want to send to a database file.
Can someone show me how to format this class's data each time and send it to/receive from a file?
If I have to use a delimiter then how do I do this correctly and receive it correctly to place in a RECEIVING vector?
Please be patient with my ignorance and teach me!
PLEASE!
C++ is my favorite programming language
-- modified at 20:15 Friday 30th December, 2005
|
|
|
|
|
I would suggest you would need to Serialize your data using CArchive .. Ive bolded those words - use them in google/your fav. search engine and you should be able to find enough examples out there (I dont have any to hand)
.. otoh, a quick look finds :-
http://www.cis.temple.edu/~wolfgang/MFC-STLPaper.PDF[^]
and, even better, a series of 3 articles written by CP guru Ravi Bhavnani, first one is at ...
http://www.codeproject.com/cpp/serialization_primer1.asp[^]
hope this gets you started
There are other ways of course .. you could
1a) open a text file for writing
1b) iterate through your vector
1c) for every class element stored, write the data components, seperated by a delimiter to the file
1d) close the file
2a) open the file for reading
2b) while not eof read a line from the file
2c) parse the line for the delimiters, giving you the data (see tokenising/delimters)
2d) create the class with the data from 2c
2e) store the class from 2d into a vector
2f) close the file
or write and read as xml .. depends what the objective of the exercise is really
'g'
-- modified at 21:48 Friday 30th December, 2005
|
|
|
|
|
I don't understand at all serialization and the CArchive class. I this stage I would be movre comfortable with straight "C++" concepts rather than mixing Microsoft's MFC concepts.
I really do need real life examples to learn from.
Thanks,
Larry
C++ is my favorite programming language
|
|
|
|
|
then I'd suggest you're going to have to put together code that achieves points 1 & 2 of my original post .. MFC has a class CFile thats useful - there's plenty of code around the net that will show you how to use it ..
the link :- http://www.tolland.k12.ct.us/ths/compsci/jeffmaynes/maynes3.pdf[^]
would be a starter ..
other than that, a good c++ textbook should also show you this... Since you brought the point up, I suggested the MFC way of doing it because your data class had 3 CString members/elements, CString is MFC - not pure C++ !!
points 1 and 2 apply wether you're using MFC or not, if not, you'll have to read what the alternative to CFile is
<modified>
you could also look at things 'like' http://www.codeproject.com/file/textfile.asp[^] and using that as a starting point - its not that different to what you'll need to do
</modified>
'g'
-- modified at 2:02 Monday 2nd January, 2006
|
|
|
|
|
Hi-
Here is my problem-- I am having difficulty getting the following to work properly:
//the following was implemented in VS 2003 using Console App (.NET)
<br />
string str ="*********";<br />
str.append("\n psinfo");<br />
str.append("\n*********\n");<br />
<br />
ofstream myfile("C:\\TEMP.txt");<br />
<br />
if (!myfile)<br />
{<br />
cout << "error opening file" << endl;<br />
return -1;<br />
<br />
}<br />
myfile << str << ShellExecute(NULL, "open", "Psinfo.exe",NULL, "C:\\",SW_SHOWNORMAL)<<endl;<br />
myfile.close();<br />
<br />
return 0;
It compiles and runs, its just after execution, when I open the file "Temp.txt", the output is not correct!
here is the output in notepad:
(start output)
*********
psinfo
*********
0000002A
(end output)
So I know that it is writing the string I created and I also know that the Psinfo.exe is executing cause I can see it on the dos prompt. However, the output from the Psinfo.exe is not writing to the text file "TEMP.txt"!
Could anyone shed some light as to why the Psinfo.exe information is not writing to the TEMP.txt file.
FYI- I created a batch file like so...
(start of .bat file)
<br />
@echo off<br />
<br />
rem This env variable stores the log file path.<br />
set PTH=C:\TEMP.txt<br />
<br />
rem Get basic information about the machine.<br />
<br />
echo ************* >>%PTH%<br />
echo * PSINFO -d * >>%PTH%<br />
echo ************* >>%PTH%<br />
psinfo.exe -d >>%PTH%<br />
(end of .bat file)
and when the batch file is executed, the "TEMP.txt" file opened in notepad is similar to the following output:
(start of output)
*************
* PSINFO -d *
*************
System information for
Uptime:
Kernel version:
Product type:
Product version:
Service pack:
Kernel build number:
Registered organization:
Registered owner:
Install date:
Activation status:
IE version:
System root:
Processors:
Processor speed:
Processor type:
Physical memory:
Video driver:
Volume Type Format Label Size Free Free
(end output)
Which is exactly the output I am trying to get in the TEMP.txt file when implemented in VC++!
Thank you for your time.
|
|
|
|
|
Why dont you shellexecute the batch file instead?
It is bit more complex in getting the output of the PSINFO.EXE when executed using the shell execute.
You need to redirect the console output
check this article for additional information Here[^]
-Prakash
|
|
|
|
|
Klerik82 wrote: myfile << str << ShellExecute(NULL, "open", "Psinfo.exe",NULL, "C:\\",SW_SHOWNORMAL)<<endl;< blockquote="">
That writes the return value of ShellExecute() to the file, which is exactly what you're seeing. It doesn't magically know you want to redirect the other program's input to your own file object (which wouldn't work anyway, since they're different processes).
Since this is a console app, you can use popen() to capture the output. Or more generally, you can set up a pipe to the file and use CreateProcess() to tell psinfo the pipe handle.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
"Just because the box has 2 gigabytes of memory doesn't mean you get to use it all!"
-- Rico Mariani, CLR perf guy
|
|
|
|
|
I am very new to VC++, so I thank you for ur direction and assistance!
Happy New Year to all!
|
|
|
|
|
I'm sure the answer is obvious but I can't seem to work it out.
I have a created a class (called Cemu) which is tagged as serializable via MFC's macros. Now in Cemu there consist a couple of CString's which I want to serialize. To complicate matters I have a list of Cemu entries stored in CemuList. What I have done when I want to dump the list to the file is loop through CemuList and call the serialize() method I created in Cemu which in turn writes out the CStrings I want to a file. That process seems to work just fine by examining the file afterwards. What I'm have trouble with is de-serializing. My initial stab at it is below but that doesn't work.
while (file.GetPosition() < file.GetLength()) {
client = new Cemu;
client->Serialize(archive);
CemulList.AddTail(*client);
}
The file containing the data has 2 Cemu serialised entries and what I'm finding is that only one gets read in. My interpretation was that the act of serializing the Cemu would move the file pointer along correctly, ie a total of 2 times but I'm missing something. Can point me in the right direction?
Cheers!
|
|
|
|
|
jbem wrote: Can point me in the right direction?
See this[^] article.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Nice work Ravi - Ive just pointed your work out to a Larry Mills, 2 posts above this one
'g'
-- modified at 21:35 Friday 30th December, 2005
|
|
|
|
|
Thanks Ravi. I initially saw these primers and had a bit of a read through all 3 of them so thanks for putting the effort in to write them up.
The thing I have a problem and which I was trying to avoid was having to store the number of items in the actual file. It seemed rather logical to me that if you know the way you stored data for a class you should be able to serialize chunks which would automatically walk the file in the right increments via the archive buffer till EOF on deserialization. I guess not.
So the thing I get out of all this is that if you have a list of objects of a type that you want to serialize then there is no other way than to store the number of objects as the first item if you ever want to recreate that list of objects ever again. I guess CArchive has no concept, that is exposed to the user, of file position based on what it has serialized just more like a buffer position internally.
|
|
|
|
|
jbem wrote: avoid was having to store the number of items in the actual file
This is a VBT (very bad thing ) because it enforces the dependency that the collection be the last (or only) data stored in the file.
jbem wrote: CArchive has no concept, that is exposed to the user, of file position based on what it has serialized just more like a buffer position internally
Correct. And nor should it, since it's really just a stream (that may be part of another stream). That's where the power of object oriented serialization comes in. If you later choose to embed your collection in another object, you don't need to change your collection serialization code as it's location agnostic.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
One of the ways that I've gotten around this is by outputting the number of elements in the list before outputting the list. Then reading that number at load time to see how many elements are getting ready to get read:
int numElements;
if( ar.IsStoring() )
{
numElements = _yourList.GetCount();
ar << numElements;
POSITION pos = _yourList.GetHeadPosition();
while( pos )
{
YourType currElement = _yourList.GetNext( pos );
currElement.Serialize( ar );
}
}
else
{
_yourList.RemoveAll();
ar >> numElements;
for( int i = 0; i < numElements; ++i )
{
YourType newElement;
newElement.Serialize( ar );
_yourList.AddTail( newElement );
}
}
That's untested code, but you should get the idea.
-- modified at 15:34 Friday 30th December, 2005
|
|
|
|
|
Thanks ToxickZero. Same solution as Ravi offered also and works fine as I just implemented it. Pity you need to keep track of the number of elements when serializing. Wish it could be done in a more dynamic fashion but it seems as it is not to be.
|
|
|
|