|
CString str = var.bstr;
Where var is type variant.
But you need to check if the var is type BSTR. For that you need to test if var.vt == VT_BSTR ;);)
In other case you need to use the VariantChangeType function to convert the variant to BSTR....
Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
I've studied XtraBuilder and (a little)
XDK, examinig the examples, and now I'd
like to begin coding myself using Visual
C++ but ... I don't know how to start
building an Xtra !!!
When I open file-new I dont't know what
to choose (even if I'd made some tests).
Somebody can help me to start?
Thanks.
|
|
|
|
|
I have a file that combine htmls and gifs.
For example the first 100 bytes is html the rest is the gifs related the html. How can I fill them to webcontrol ? Can I read them to memory and put the memonry to webcontrol (IE) ?
Please give me some hints ? Thank you.
|
|
|
|
|
u have to cut the file into several files: the html file, and one for each gif, and then Navigate2 the html file!
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi,
have you ever come across some info on this?
Thanks
R.
|
|
|
|
|
|
I'm building a project about download files.
I should get the length and last modify date of remote file.
How should I do this ?
Thank you very much!
|
|
|
|
|
You need to use either FTP or HTTP depending on what kind of server the files are being hosted on. Check codeproject for code on how to handle both of those protocols.
http://www.codetools.com/internet/[^]
Todd Smith
|
|
|
|
|
Hi, Todd,
Thank you very much!
|
|
|
|
|
Hi,
I am working on printing a List Box contents, so far it has worked ... except that I could not change the "Text size", here is a part of my codes:
<br />
CFont Font;<br />
LOGFONT lf; <br />
CDC dc;<br />
<br />
memset(&lf, 0, sizeof(LOGFONT::ZeroMemory(&lf, sizeof(LOGFONT));<br />
lf.lfHeight = -MulDiv(10, dc.GetDeviceCaps(LOGPIXELSY), 72);<br />
strcpy(lf.lfFaceName, "Arial"); <br />
<br />
Font.CreateFontIndirect(&lf);<br />
dc.SelectObject(&oFont); <br />
CString text("A") ;<br />
CSize csText = dc.GetTextExtent(text) ;<br />
----------------------------------------------- (some more detail)<br />
m_listbox.GetText(line_printing, text) ;<br />
dc.DrawText(text, CRect(x, y, x + Info.m_rectDraw.Width(), y + csText.cy), DT_EXPANDTABS) ;<br />
<br />
*) I tried to change lf.lfHeight, but the result is that I only changed the spacing for vertical printing! What ever I change that or lf.lfFaceName ... the "Text size" printing out ... has never been changed!
Can someone help me on this, I am really appreciate it ... if provide me an Email ddress, I will send a small zip about my small project (just to try the printing)!
Many thanks,
|
|
|
|
|
Are you sure that dc you're using to call GetDeviceCaps is actually printer DC?
Also, you may use CFont::CreatePointFont to avoid bit-twiddling.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Hi,
I did try to use as your suggestion:
VERIFY(oFont.CreatePointFont(80, "Arial", &dc)); // 120 = 12 point font
for replacing:
// oFont.CreateFontIndirect(&lf); // Create the font.
// dc.SelectObject(&oFont); // RIA, select he font into the DC
The result was the same Text size! Someone knows why?
- For the GetDeviceCaps is actually printer DC? I think Yes, because we have to use to calculate the Paper size ... and so far it is OK!
Many thanks for any help
|
|
|
|
|
Ok I am going to try and explain this without confusing both you and myself. I have a file that I am writing custom CObjects to. The first thing written/read from the file is the number of objects that are in the file… so I know how many times to read from the archive.
Say that number is 5, and then I close the file, open it again, and rewrite more objects now the number is 10. Do I have to clear the file and rewrite all the objects? If I do not clear the file, and just write at the start position or will this corrupt the file because it will be overlapping the first object.
To make it even more confusing, do I have to include the number of objects, or is there an easier way. My overall objective is to create a log file, so I subclassed CObject, to create my own objects… to make it easier to write.
If you have any answers to one or all of my questions, I would GREATLY appreciate it. I have read MSDN, but am very confused about how it works… I know it’s hard to create your own file format. Thank you for your time.
"Best file compression around: DEL *.* = 100% compression."
<><><><><><><><><><><><><>
Matthew R. Miller
mattrmiller@computersmarts.net
www.computersmarts.net
|
|
|
|
|
Hi Mathew,
I'm reasonably sure CArchive is only a streaming format, which means you can't selectively write to a part of the file. ie. In your example the count of objects at the start. Appending to an existing archive should work ok.
I use a similar technique to the one you describe to manage an array of Style Sheets in ED (see sig). When I want to save the style sheets array I recreate the file from scratch as follows:
if ( bStat = SSfile.Open( m_SSFileName, CFile::modeCreate | CFile::modeWrite | CFile::shareExclusive, &FileException ) )
The count is written at the start of the file.
If you want to be able to append to the file and modify a header record I don't think CArchive is appropriate.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
|
Just a quickie,
I have one member function
HWND CAutoRestartDlg::GetProcessWnd()<br />
{<br />
... <br />
EnumWindows((WNDENUMPROC)CAutoRestartDlg::GetWndProc,(LPARAM)0);<br />
....<br />
}
and also my callback function:
BOOL CALLBACK CAutoRestartDlg::GetWndProc(HWND hwnd, LPARAM lparam)<br />
{<br />
...<br />
}
When I try to compile, I get error C2440: 'type cast' : cannot convert from '' to 'int (__stdcall *)(struct HWND__ *,long)'
What am I doing wrong? Would appreciate some help. Sorry if it sounds a bit thick but I am feeling very thick at the moment.
Many thanks
Adam.
www.beachwizard.com/travelogue[^]
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
|
Thanks Joaquin,
I can't see for looking some days. I appreciate your help!!
Cheerio for now and thanks once again.
Adam.
www.beachwizard.com/travelogue[^]
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
Make sure GetWndProc is declared as a static function in your CAutoRestartDlg class. Most any time you define a Win32 API callback function inside a class you need to make the function static. This is because the Win32 API is written in C and C can't handle C++ classes and their polymorphic abilities. The API needs to know at exactly what position in memory your function resides so that it can call it. Polymorphism allows run-time determination of function addresses. Static functions -and static member variables, too- are allocated once when your app begins and never move for the duration of your app's existence. Only one copy of a static function exists in memory for the entire class; regardless of how many instances of the class you create.
Static functions are basically identical in nature to any old C-style function you'd create outside of your class. The only difference is that they're located in your classes' namespace, so you can keep things neat and know where to look for the code. That's really the only reason why they're even allowed in a class; you don't get any object-oriented features with static functions.
One additional note to preempt further frustration... static functions inside C++ classes cannot directly access anything inside the class except other static member variables or static functions. IE if you had an integer member variable named m_iMyVar, you could not read it nor set it unless it were also declared as being static. This is because only one copy of the function for the entire class exists; it would not know which object instance to use when setting the member variable or calling the other function. If you want to actually use something inside your CAutoRestartDlg class you'll have to use the LPARAM portion of your call to EnumWindows() and pass along a pointer to the class or a struct which contains a pointer. I can whip up some code if you'd like to see an example of this.
Sorry for the over-explanation if you knew this stuff already I guessed from your code that you probably already tried various casts.
Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
|
|
|
|
|
Hey Ty,
That's excellent. A big THANKS! Really, more explanation is better than less, for me anyway. I got really fed up late last night wondering I kept getting the error message and not being able to figure it out. It's just that the explanation of the error does not give any indication that the function would have to be declared static. Hence my frustration!
Thanks once again! Totally appreciated.
Adam.
www.beachwizard.com/travelogue[^]
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
Okay, now you have managed level 1, let's go up to level 2
Using only static member functions (also called class functions) or ordinary C functions as callbacks is boring and odd. But you can use adapters to "translate" a call to a static function seamless into a call to a real member function.
If you are interested in more technical details about the "callback has to be static" issue and a complete solution for it you may want to check out my article Use member functions for C-style callbacks and threads - a general solution.
However, you don't have to read the whole article, you could also just use the provided adapters. It allows you to write code as simple as the following:
#include "stdafx.h"
#include "win_adapter.h"
struct DATA { int foo; double bar; };
class Test
{
public:
virtual BOOL WindowLister( HWND hWnd, const DATA& data )
{
printf(" Window: %p\n", hWnd );
return true;
}
void DoStuff()
{
DATA someData;
win::EnumWindows( this, &Test::WindowLister, someData );
}
};
Programming is fun!
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
What is the best way to smooth window movement on static controls such as picture controls in msvc++ and mfc.
i currently use,
hStruct.HSliderCover = iLoadBitmapFromFile( "graphics/slider_cover.bmp", 0 );
m_picSliderCover.SetBitmap( hStruct.HSliderCover );
m_picSliderCover.SetWindowPos( &wndBottom, 0, 0, 553, 62, SWP_NOMOVE );
CRect rect;
m_picSliderCover.GetWindowRect(rect);
SetTimer( SliderTimer, 1, NULL );
//slider timer
if( nIDEvent == SliderTimer )
{
rect.left++;
m_picSliderCover.SetWindowPos( &wndBottom, rect.left, 420, 0, 0, SWP_NOSIZE );
}
any help would be great.
|
|
|
|
|
There are most likely lots of ways to do this, including the one you're using. My two suggestions are:
- Use a borderless popup window displaying the bitmap, move it - should be accelerated on any not-completely-worthless OS+video card. Or,
- Save an image of the portions you are covering to memory, and then use a separate in-memory bitmap to draw part of it covered by your slider each timer interval; then draw the complete image to the screen in one go.
Shog9
------
If you really what to get shitfacde tell a crowded bar that is is yourt borthday and hife your wallet. you ka will many more friends.
- David Wulff, Brithday selebrations, 9/19/02
|
|
|
|
|
On the users machine, my install program will register the VB com dll automatically. Question is where should I put my VB Com dll? Does it matter? Or will the app go to the registry and locate it itself? The method I'm using to hook the dll has code like :
_ClRemoteCall p;
p.CreateDispatch("DllwithForm.Class1");
and I go through the class wizard .
Thanks,
ns
|
|
|
|
|
If the DLL is specific to your progam (as I guess it is), then it is best to copy it to the target directory where all other stuff belonging to the app inhabits. The registration process takes note of the path where the DLL is, so you have complete freedom to choose its location.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|