|
Hi All
I am geting error when i am useing COleDataObject.I got some example code from net.It's very help full for me but when i am use the code then i am geting error.
COleDataObject odj1;
if( odj1.AttachClipboard() )
{
if( odj1.IsDataAvailable( CF_HDROP ) )
{
STGMEDIUM StgMed;
FORMATETC fmte = { CF_HDROP,
(DVTARGETDEVICE FAR *)NULL,
DVASPECT_CONTENT,
-1,
TYMED_HGLOBAL };
if( odj1.GetData( CF_HDROP, &StgMed, &fmte ) )
{
HDROP hDrop = (HDROP)StgMed.hGlobal;
UINT cFiles = ::DragQueryFile(hDrop, (UINT)-1, NULL, 0);
CString szText;
char szFile[MAX_PATH];
szText="";
for( UINT count = 0; count < cFiles; count++ )
{
::DragQueryFile(hDrop, count, szFile, sizeof(szFile));
szText += szFile;
szText += "\r\n";
}
m_pRich->ReplaceSel(szText);
if (StgMed.pUnkForRelease)
{
StgMed.pUnkForRelease->Release();
}
else
{
::GlobalFree(StgMed.hGlobal);
}
return;
}
}
}
error geting
error C2079: 'odj1' uses undefined class 'COleDataObject'
error C2228: left of '.AttachClipboard' must have class/struct/union
error C2228: left of '.IsDataAvailable' must have class/struct/union
error C2228: left of '.GetData' must have class/struct/union
Plz help me
|
|
|
|
|
|
How can I extract images of a website like some programs is it possible on the c++? if yes how?
|
|
|
|
|
You first need to get access to the HTML source that has currently been loaded.
This differs from browser to browser.
In IE you can write a BHO.
In Mozilla based browsers you can like Firefox and Netscape you can write an extension.
Then you can use HTMLDOM/Javascript/XPComm to access all the IMG tags to fetch the images.
«_Superman_»
|
|
|
|
|
If you know the URL of the image, try URLDownloadToFile() .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
i want to know how to call a DLL
and what is the difference between both
1.cocreate
2.Import dll
Thank you...
vikas da
|
|
|
|
|
tasumisra wrote: i want to know how to call a DLL
You don't call a dll. You first load the dll and when this is succesfull you can retrieve the addresses of functions in the dll and call those functions.
|
|
|
|
|
|
tasumisra wrote: 1.cocreate
Do you mean CoCreateInstance [^]?
BTW: What about DLL 's documentation [^]?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
There are two methods generally.
One:Dynamic load DLL
HINSTANCE hInst;
//DLL2.dll must in current directory.
//Implement on a button clicked event.
hInst=LoadLibrary("DLL2.dll");
typedef int (*ADDPROC) (int a,int b);
ADDPROC add=(ADDPROC)GetProcAddress(hInst,"Add");
if(!add)
{
MessageBox("Failed to get address!");
return;
}
int ret=add(5,3);
CString str;
str.Format("%d",ret);
MessageBox(str);
Two:Static load DLL
First place DLL2.dll and DLL2.lib into current directory,
then set project/settings/Link to load DLL2.lib
_declspec(dllimport) int add(int a,int b);
void CDLL2TestDlg::OnButton1()
{
int a=add(5,5);//use this method from dll
}
studing is processing in this life.
|
|
|
|
|
what does the declaration (:8, :3, :1, etc.,) mean in the folowing struct?
struct CELL {
unsigned short character : 8;
unsigned short foreground : 3;
unsigned short intensity : 1;
unsigned short background : 3;
unsigned short blink : 1;
} screen[25][80];
|
|
|
|
|
character is an unsigned short value but will occupy only 8 bits and not 2 bytes.
foreground is an unsigned short value but will occupy only 3 bits and not 2 bytes.
Similarly other fields of the structure.
For example if valid values for intensity are only 0 and 1, you only need 1 bit to represent that.
That is the idea here.
«_Superman_»
|
|
|
|
|
Thanks for your reply.
In case the size exceeds the predefined size what will happen?
|
|
|
|
|
If value cannot fit into the number of bits allocated, it will then overflow to the next field.
It is up to the application to limit that.
«_Superman_»
modified on Wednesday, January 7, 2009 3:11 AM
|
|
|
|
|
Superman's answer is incorrect - the behaviour on assignment of a value that cannot be held in the bit-field is implementation (i.e. compiler) dependent - that's what the C++ Standard says (section 4.7p3), anyway, and I suspect the C standard will be much the same.
Certainly, for Microsoft C/C++, values are truncated to what will fit in the bit-field. Consider this code:
#include <stdio.h>
struct X
{
unsigned int a : 3;
unsigned int b : 3;
};
int main(int argc, char** argv)
{
{
struct X x = {0};
x.a = 15;
printf("x.a = %d, x.b = %d\n", (int)x.a, (int)x.b);
}
{
struct X x = {0};
x.b = 15;
printf("x.a = %d, x.b = %d\n", (int)x.a, (int)x.b);
}
return 0;
} This produces the following output when compiled as C or C++:
x.a = 7, x.b = 0
x.a = 0, x.b = 7
|
|
|
|
|
|
KASR1 wrote: what does the declaration (:8, :3, :1, etc.,) mean in the folowing struct?
They are the number of bits assigned to each field. The author wanted to store the data in 2 bytes (unsigned short) and specify names for each set of bits within those bytes. This is normally considered non-portable (but legal) C-Code. There are other more portatable ways of doing the same thing, but they require a little more work by the programmer.
Note that they defined exactly 16-bits; if they had specified just one more bit, it would changed the memory block size to 32-bits (unsigned int = 4 bytes on 32-bit compilers) unless some compiler specific flag was set to compact it to single by boundries.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
How to read unicode text files (japanese chars) in C prog?
|
|
|
|
|
There is no difference in reading ascii files and unicode files.
The difference is in how you interpret it.
The windows APIs and the C runtime functions provide a void pointer into which the read contents will be stored. So if you give the correct number of bytes to read all is fine.
How you interpret the contents of the buffer after the read is where the difference is.
«_Superman_»
|
|
|
|
|
I have not done it in a while, but it is basically the same as reading ASII files. The difference being that you use the functions that have a 'w' as part of their name. The 'w' implies that it is expecting the 'wchar_t' type (16-bits: unsigned short) instead of the 'char' type (8-bits: signed char) when reading. If you are using a Microsoft library then you can use the '_ts...' macros which will use the 'wchar_t' functions if UNICODE is define; otherwise it will use the ASCII functions.
I hope that helps.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Hey there,
I have a string which includes Turkish chars. And a regex pattern.. my mfc app is compiled with MBSC (I am pretty sure)
I got an error at the last letter says unhandled exception..
my string is (i am not sure if you can see it properly) "paylaş"
so last letter makes rgx throws an error.. I kinda deep search about the error I would like to write it if needed..
So what am I missing why it fails on turkish chars? I do not define any type of CharTraits I mean I create my variable in this way: CAtlRgx<> myregx; did not specify char type between "<" and ">"
thank you all..
|
|
|
|
|
CAtlRECharTraitsA contains the traits for ANSI characters, For multibyte characters, see CAtlRECharTraitsMB.
By the way Microsoft removed ATL server support from VS 2008 including
CATLRegExp class.
Try using basic_regex<> from VC++ 2008 Feature Pack MFC Enhancements.
|
|
|
|
|
Dear All,
Is there any way to create global objects to all the classes in the MFC dialog based application ? I want to use the object of one class from the other class, but I want to create the object only once.
The object created for each class should be a singleton object.
Please help me.
Thanks in advance.
|
|
|
|
|
And what is your trouble about?
You may use static members or (as you already are aware) the singleton design pattern.
BTW: the (in)famous theApp object is a (wizard created) sample of a global MFC object.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
My exact problem is that, I am using four dialog in my MFC application. I want to open the a dialog from another dialog.
I am using OnCancel() for closing the current dialog and use DoModal() to open the other dialog. If I do like this for more no. of times then I got assertion and I found that this happens due to memory overflow due to the recursive call of DoModal().
I want to create global (single) objects for all classes and using those objects I need to hide the window and show the window instead of using OnCancel and DoModal.
But I am not so experienced in defining global objects and static objects. Please help me with some samples.
P.S : I dont want to use Property sheet or Tabbed dialogs or MDI.
Thanks in advance
|
|
|
|