|
thank you; that code worked;
it took me a little bit to
get the right hWnd, but once I
did, I was able to read the selected files..
thanks again.
sas
|
|
|
|
|
I hate to be a newbie but I need this. I made an ActiveX that its only function is return a string with some information of client PC but this doesn't matter ... the problem is... When I invoke my method in my HTML file my method doesn't return any string... I don't know how to make this but I tried by this way:
/****** IDL FILE *********/
dispinterface _DMyActiveX
{
properties:
methods:
[id(60666)] char* GetString();
};
/******Control CPP File*******/
BEGIN_DISPATCH_MAP(CMyActiveXCtrl, COleControl)
DISP_FUNCTION_ID(CMyActiveXCtrl, "GetString", 60666, GetString, VT_EMPTY, VTS_NONE)
END_DISPATCH_MAP()
char* CMyActiveXCtrl::GetString()
{
return "TestString\0";
}
/******** CONTROL H FILE *****/
// Dispatch maps
DECLARE_DISPATCH_MAP()
afx_msg char* GetString();
/************************************************************/
This is what I changed on original VC++ files... this method works as well to show an MessageBox or an Dialog but it doesn't to just return a string... I don't know the reason... maybe the afx_msg... Can anyone help me??? Thanks!!!!
Wender Oliveira
.NET Programmer
|
|
|
|
|
Maybe since you are not "really" allocating any memory to set the return value, the string value gets cleaned up when the method exits. Try allocating some memory and setting it to the value you want. Do not forget to free the memory when the callee is done using the value.
|
|
|
|
|
I didn't understood... I really haven't experience with C++ and this is the reason that I don't know how to make what you said... Can you show me an example?
I changed the method to:
void CMacAddressCtrl::GetMacAddress()
{
MessageBox("TestString");
}
and it works as well... But when I try to return the char* it returns <null>...
Wender Oliveira
.NET Programmer
|
|
|
|
|
Wender Oliveira wrote:
I really haven't experience with C++
Starting out in C++ with an ActiveX control probably isn't the best path, IMHO.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hello again, I posted an article last week about how to create a non-rectangular dialog with c++. Well, the solution was to apply Regions to do this but my problem was that I need to smooth my edges because the image is round.
I'm trying to use DirectX to do it, but I don't know if it's possible. I need some help with it and if somebody knows some related article, please, say me.
Thanks.
|
|
|
|
|
Hi!
I am using c++ win32 api.
I declared a string variable and I can append some values to it by the append function.
Everything goes fine if I don't enter a value longer than 15 chars but at 16 it craches...
Can anyone help me?
the code is here:
<br />
...<br />
string mycode;<br />
char values;<br />
...<br />
mycode.append("Hello the value you append is: ");<br />
int len = GetWindowTextLength(GetDlgItem(hwnd, IDC_VALUE));<br />
if(len > 0)<br />
{<br />
GetDlgItemText(hwnd, IDC_VALUE, &values, len + 1);<br />
} <br />
mycode.append(&values);<br />
mycode.append(" is it right?");<br />
SetDlgItemText(hwnd,IDC_CODE,mycode.data());<br />
Thank you very much in advance for your answers!
Well... I am a beginner ...
|
|
|
|
|
...OK I found my error...
The error was in the way I was getting the value from the edit box.
I should have done this:
<br />
...<br />
string mycode;<br />
char values[MAX_PATH];<br />
...<br />
mycode.append("Hello the value you append is: ");<br />
int len = GetWindowTextLength(GetDlgItem(hwnd, IDC_VALUE));<br />
if(len > 0)<br />
{<br />
GetDlgItemText(hwnd, IDC_VALUE, values, len + 1);<br />
} <br />
mycode.append(values);<br />
mycode.append(" is it right?");<br />
SetDlgItemText(hwnd,IDC_CODE,mycode.data());<br />
...I told I was a beginner...
Well... I am a beginner ...
|
|
|
|
|
> if(len > 0)<br />
> {<br />
> GetDlgItemText(hwnd, IDC_VALUE, values, len + 1);<br />
> } <br />
Be sure that len does not exceed the capacity of the buffer you are copying into; in this case, values , which is of MAX_PATH length.
I would change the code to something like this:
GetDlgItemText( hwnd, IDC_VALUE, values, MAX_PATH );
It is OK to ask for "too much text" in this case, the function will copy only what is available in the window or how much your buffer can handle, which ever is less.
Peace!
-=- James
Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"! Articles -- Products: Delete FXP Files & Check Favorites
|
|
|
|
|
I do not know how to focus my question so bear with me.
When you print a document and view it in the pending print queue it has a title column. Is there an API to set the print title?
thanks
|
|
|
|
|
The DOCINFO structure you pass to StartDoc sets this. If you are not calling StartDoc yourself, you can trace into MFC and see if it uses any stuff you can change, or if it is set in an overridable function.
|
|
|
|
|
Following the earlier post ( yesterday ) about slow string generation.
I now use reserve to allocate a generous size to my string, since I don't know the exact size ( even the approximate size ) of the generated string.
Is there a way to reserve a base size, and have the string grow by a certain larger size, instead of small size ? is that what allocator in STL are ?
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
If you have decided on using STL and your requirements are to generate large strings by multiple appends you might want to look at the ostringstream class.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
it does not change anything.
if I simply change my std::string with std::ostringstream and do something like
std::string m_String;
m_String.append( someText );
or
std::ostringstream m_Stream;
m_Stream << someText;
it simply, as I understand it, another way of doing the same thing.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
You can preallocate size in the string by calling the std::basic_string::reserve(...) method. But it seems you already know this...
You could copy the implementation of basic_string and create your own with a higher reallocation granularity.
You could also pay attention to the current size vs. capacity (for example, if you are building the string in a loop, check the values at the beginning of the loop) and manually reallocate it to twice its current capacity so that it behaves more like a vector reallocating...
Peace!
-=- James
Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"! Articles -- Products: Delete FXP Files & Check Favorites
|
|
|
|
|
Sir,
I am developing an Win32 application that involves events and notification.
I am developing a simulator that fires an event and generates notification through threads.
Pls correct me If I am going wrong.
1. Develop a Win32 Application.
2. Inside Winmain, do the following.
2.1. Create a thread
2.2. Create a Handle
2.3. Call CreateEvent and assign the handle to the first.
2.4. Call the message loop
3. Inside the thread call WaitforMultipleObjects();
3.1 Use switch case To catch the event
3.2 Now when appropriate events are fired ,I want to get notification.
3.3 Where will I declare events ? Will it be in the header file or in the dll.
What further do I have to do to achieve this?
Can somebody help me with a piece of code here?
Regards
Tiger
|
|
|
|
|
Your simulator thread can post messages to a window, if your main thread created a window, or threads can post messages to each other with PostThreadMessage.
You can only wait on, I think, 32 events at any given time, so you don't want EVERY possible thing your simulator can do to be a different synchronization event.
It would be better to create a thread-safe queue, and your simulator thread puts 'data events' into the queue and posts a message or sets a synchronization event to indicate that data is available in the queue. The thread consuming the data can wait on the synchronization event and then go read the queue. If it is a window, it would go read the data queue and process data until it had read all items out of the queue, then it would be waiting again.
|
|
|
|
|
Thx for the response.
Should the events be defined in a header file.
I call a function which is already defined in a dll /in my application.
Will that function generates an event like I press a button which in turn calls a function.
The event names should be defined #define.
Can u help me with a code snippet.
Regards
Regards
Yadagiri
|
|
|
|
|
Hello,
I would like to create a GDI+ GraphicsPath vector by
std::vector<graphicspath> m_Paths;
and its iterator
std::vector<graphicspath>::iterator pathIter = m_Paths.begin() + m_iPath;
in my application view class in header and cpp file. But the compliler gives this error, What can be the reason for this error ? Thanks for your interest.
Compiling...
ImageMarkerView.cpp
d:\Programs\Microsoft Visual Studio .NET 2003\Vc7\include\vector(810) : error C2248: 'Gdiplus::GraphicsPath::GraphicsPath' : cannot access protected member declared in class 'Gdiplus::GraphicsPath'
d:\Programs\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusPath.h(862) : see declaration of 'Gdiplus::GraphicsPath::GraphicsPath'
d:\Programs\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusPath.h(18) : see declaration of 'Gdiplus::GraphicsPath'
d:\Programs\Microsoft Visual Studio .NET 2003\Vc7\include\vector(809) : while compiling class-template member function 'void std::vector<_Ty>::_Insert_n(std::vector<_Ty>::iterator,std::vector<_Ty>::size_type,const _Ty &)'
with
[
_Ty=Gdiplus::GraphicsPath
]
e:\Work\Cpp\ImageMarker\ImageMarkerView.h(75) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
with
[
_Ty=Gdiplus::GraphicsPath
]
Generating Code...
Compiling...
ImageMarker.cpp
Generating Code...
Build log was saved at "file://e:\Work\Cpp\ImageMarker\Debug\BuildLog.htm"
ImageMarker - 1 error(s), 0 warning(s)
---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped
|
|
|
|
|
I realized that I missed some parts, and I now add it .
the declarations should be like
std::vector<graphicspath> m_Paths; instead of std::vector m_Paths;
and
std::vector<graphicspath>::iterator pathIter = m_Paths.begin() + m_iPath; instead of std::vector::iterator pathIter = m_Paths.begin() + m_iPath;
Thanks.
|
|
|
|
|
I am a newbie with MAPI and needed some help .you see i am
writing a program which will import accounts,profiles and folders
from a PC and save it in some place so that the account information
can be plugged in to another PC .
So far i could enumarate the folders and the contacts and
profiles.But how do you enumerate the user accounts from the
profiles? is there any way MAPI lets us do that ?
I even found a way of importing account info of the default user.So
if MAPI lets me chnage the default user then i can set each account
to default one by one and then enumerate them.Is that possible?
I know of several VB application which does this , but i am writing
this application in VC++ 6.0 .however i figured that using a COM
object won't be a big troubel if i know the right API's and all.
Can anybody help ?
Thanks in advance.
Regards
Kane
Some guys hack just to get themselves a girlfriend.What a pathetic reason huh ?
|
|
|
|
|
|
well how do u think will i b able to achieve my goal then ? I could retrieve all account info from the registry, but they are all encoded in some way , not just hex values.Anybody knows how to decode them ?
Regards
Kane
Some guys hack just to get themselves a girlfriend.What a pathetic reason , huh ?
|
|
|
|
|
How can I set the position of a modal window ?
When I call DoModal method, the window is shown but I don't know
how to the the window position...
Thanks a lot !
|
|
|
|
|
in the OnInitDialog
call SetWindowPos or MoveWindow
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|