|
By the way, my birthday is November 16 too!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
dude where did you grow up! you didn't say thanks once for the free help you got?
Yours Truly, The One and Only!
|
|
|
|
|
George that was not directed at you ... personally my help stops when someone doesn't thank you for your time.
Yours Truly, The One and Only!
|
|
|
|
|
Thanks for your concerns! I don't expect to get thanked but it is always welcomed.
Regards,
George
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi
CreateWindowEx(0, "AtlAxWin71", "MSHTML:<iframe src=\"http://www.google.com\"></iframe>", ...);
this code works but when I use IHTMLDocument2::Write() with the same html code, iframe doesn't appear
when I refresh the page(right click->refresh), iframe appear
an idea to solve this problem ?
tanks
|
|
|
|
|
it works with IHTMLLocation::reload() after Write()
|
|
|
|
|
Hi
I am having a typical problem from last one day.I am being able to writ into a text file from my vc++ application,but I am not being able to read the file.actually I need to write something in the file and I need need to again read the file.here is y code which is working fine for writing to file:
FILE *fp=NULL;
fp=_wfopen(lstr,_T("w+"));//lstr is having the path to the file
fwrite( strTitleCurrentDate, sizeof(TCHAR), strTitle.GetLength()/** sizeof( TCHAR )*/, fp );
fclose( fp );
this code is working fine but
CString strTitle1;
newBuffer=strTitle1.GetBuffer(strTitle1.GetLength()* sizeof( TCHAR ));
LPTSTR lstr=strPath2.GetBuffer(strTitle.GetLength()* sizeof( TCHAR ));
FILE *fp=NULL;
fp=_wfopen(lstr,_T("a+"));
while(!feof(fp))
fread( newBuffer, sizeof(char), 100/** sizeof( TCHAR )*/, fp );
fclose( fp );
This piece of code really meking me frustrated because the data in file I am being able to read which actually should be "15th june 2007" is coming as "15th june 2007SID",from where this SID is coming?One more thing is that after this code of file reading if I take any CString variable and try to display it in a message box,it is showing the value "15th june 2007SID" whereas it should show blank.I am getting crash also in my application may be due to this problem.Plz help me to solve this problem with code,because it will help me a lot.Plz help me as early as possible because the deadline is coming and I am being frustrated.I also have to read data in a text file line by line which is also not being possible for me.Plz help me with code.
|
|
|
|
|
Here are a couple of problems with this code
1) GetBuffer() memory has to be released with ReleaseBuffer
2) fwrite( strTitleCurrentDate, sizeof(TCHAR), strTitle.GetLength()/** sizeof( TCHAR )*/, fp );
How do you decide to write strTitleCurrentDate to the length of strTitle, they are not related ... Correction strTitleCurrentDate.GetLength()
3) Here is even more ambiguous code
CString strTitle1;
newBuffer=strTitle1.GetBuffer(strTitle1.GetLength()* sizeof( TCHAR ));
What is the size of allocation ? strTitle1 is a zero length string! Zero and you decide to read
fread( newBuffer, sizeof(char), 100/** sizeof( TCHAR )*/, fp );
100 bytes to this buffer.
Shouldn't this be
fread( newBuffer, sizeof(TCHAR), strTitle1.GetLength(), fp );
if your allocation was right ?
However it should be just
TCHAR myFileBuffer[1024];
fread( myFileBuffer, sizeof(TCHAR), 1024, fp );
why use GetBuffer ?
Remember when dealing with a char pointer, when you cross what you have allocated, you are writing in to other non allocated memory. You have to always allocate for the string terminator. Any such memory overwrite results in crash, usually later in the code.
How to use google
type "how to read a text file line by line" and see the google results, open the second link and it has the following piece of code for a similar task. Please modify this code to get your stuff done. So another advice, try to use google much more with different search strings representing the same question.
#include <iostream>
#include <fstream>
#include <strstream>
using namespace std;
int main()
{
char buffer1[2048];
char buffer2[2048];
istrstream ostr1(buffer1, 2048);
istrstream ostr2(buffer2, 2048);
int values1[100];
int values2[100];
int c=0;
ifstream fin("data.txt");
fin.getline(buffer1, 2048);
fin.getline(buffer2, 2048);
while (ostr1 >> values1[c])
{
ostr2 >> values2[c++];
}
for (int i=0;i<c;i++)
{
="" cout="" <<="" values1[i]="" ":"="" values2[i]="" endl;
="" }
good="" luck,
santhosh
=""
<div="" class="ForumSig">Live and let live
|
|
|
|
|
can any please suggest which tool is available for preparing the documentation for atl component.
|
|
|
|
|
I've not used it but C++ devs recommend this: Doxygen[^]
Kevin
|
|
|
|
|
I want to implement address book like how microsoft outlook does with the following interface.
IContacts //maintains all the IContact interfaces
IContact //store the details of the contact.
I can get IContact by calling the IContacts->Item(i) method.can any one give me some ref to do this type of implementation
Thank and Regards.
|
|
|
|
|
Hi,
I'm planning to implement a chat server + a chat client as a learning exercise for my ATL/COM/DCOM.
As part of that first I would implement a chat server which is a local server and a chat client. Please suggest if the following is possible, if true how.
Clients register their callbacks by using Advice() (Of course, I would do FindConnectionPoint(), before that ). My doubt is is there any way to send the notification from the server to all the clients? and also can the server select the client to which it has to send the notification.
For Example: User1, User2 are currently logged in. If user1 sends a message to User2 by using SendMsg(from, to, msg) of IChatServer, can the server alert client of User2.
Otherwise can server broadcast the event??
Thanks and regards,
Raja Pratap
|
|
|
|
|
Raj Prathap wrote: My doubt is is there any way to send the notification from the server to all the clients? and also can the server select the client to which it has to send the notification.
It's not clear to me what you mean by "chat server" and "notification".
When someone talks about a chat server to me I interpret it as the MSDN sample CHATTER/CHATSRVR[^], but the notification you're talking about feels like a callback on a source interface from a COM server to its client (AKA a COM event).
If the notification is a COM event, the answer is that the server keeps track of its clients in a container; a list, vector or array. When an event is generated the container is walked through notifying all registered clients.
If you want to skip one of the clients you have to write your own code to do that.
A small thought:
You don't have to use the connection point concept, in fact Don Box recommends not to use it in his book Effective COM[^].
You can create your own Advise() method and put whatever functionality in it that you want and/or need.
But if you're new to this it could be a good starting point using the connection point concept to understand how it works.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
|
I think Nenad re-released it in order to include a sample showing how to use the new TabView - might want to check you've got the most up to date version.
|
|
|
|
|
I was wondering where I could find the Docs on learning WTL, I know my way around MFC and ATL so I am sure I can leverage what I've learned there.
TIA
Yours Truly, The One and Only!
|
|
|
|
|
Hello
I have tab Control on OCX and in the one Tab i have inserted one MFC Dialog which contains List Control.
I want to Set Tool Tip on that List Control.
I have Tried following Events :
OnToolHitTest &
OnToolTipText
these work fine in simple MFC but
OnToolHitTest event does not get called in my application.
Please Help
Rajput
|
|
|
|
|
The MainFrame of my WTL application contains a splitter window.
The left pane of this window is derived from CCheckListViewCtrl,
whereas the right one is derived from CRichEditCtrl.
Items in ListView (or, rather, text strings of items)
represent headers of a collection of texts.
Initially Item[0] is selected in the left pane, and the corresponding
text Texts[0] is printed in the right pane.
Now I wish every time when (multi) selection
in the left pane is changed, the left pane to (re)print
all texts Texts[i] with selected indices i.
My derived ListView class contains
a member stl::vector<int> selectedIndeces,
containing indices of all selected items.
This vector can be updated in time,
if one adds appropriate message handlers
(for ListView)
for KEY_UP/KEY_DOWN keystrokes, as well as
for all kinds of mouse clicks (left, right, double).
My first question is: do there exists
the notification message (similar to LBN_SELCHANGE
for ListBoxes) produced by CCheckListViewCtrl
any time the selection is changed, in no matter which
way -- via keystroke or mouse click?
If yes, how one can catch this message in parent
CMainFrame? I.e., what kind of message handler
is to be added to CMainFrame's message map?
This is necessary, because only CMainFrame
has access to the whole business logic of the application,
in particular to the array of texts Texts[].
|
|
|
|
|
Vlad0 wrote: My first question is: do there exists
the notification message (similar to LBN_SELCHANGE
for ListBoxes) produced by CCheckListViewCtrl
any time the selection is changed, in no matter which
way -- via keystroke or mouse click?
I think LVN_ITEMCHANGED is what you want. It is sent whenever an item changes someway - that includes when the item state changes - and the item state will change when the item is selected or de-selected.
Vlad0 wrote: If yes, how one can catch this message in parent
CMainFrame? I.e., what kind of message handler
is to be added to CMainFrame's message map?
It'll be related to NOTIFY_HANDLER(_EX) - I'm afraid I don't have access to a machine with WTL on at the moment (I use OS X at home), so I can't tell you outright. I suspect Michael Dunn's articles on WTL (here's the one about splitters[^]) will tell you all you need to know - I've always found them very useful!
HTH!
|
|
|
|
|
Stuart Dootson wrote: I think LVN_ITEMCHANGED is what you want. It is sent whenever an item changes someway - that includes when the item state changes - and the item state will change when the item is selected or de-selected
It'll be related to NOTIFY_HANDLER(_EX) - I'm afraid I don't have access to a machine with WTL on at the moment (I use OS X at home), so I can't tell you outright.
I've installed an excellent VS add-on: WTL Helper
by Sergey Solozhentsev http://www.codeproject.com/macro/wtlhelper.asp[^]
It inserted an adequate message handler for LVN_ITEMCHANGED
into Message Map of CMainFrame:
NOTIFY_CODE_HANDLER_EX(LVN_ITEMCHANGED, OnLvnItemChanged)
and created the prototipe of the handler:
LRESULT CMainFrame::OnLvnItemChanged(LPNMHDR pnmh)
{
LPNMLISTVIEW pnmv = (LPNMLISTVIEW)pnmh;
//If the iItem member of the structure pointed to by pnmv is -1,
//the change has been applied to all items in the list view.
return 0;
}
for this handler.
To test the handler I added first the code ignoring the parameter pnmv:
m_wndView2.AppendText(L"Item changed!\n");
Here m_wndView2 is the right pane, i.e. rich edit control.
This code produced one strange phenomenon:
if one clicks with the mouse on some non selected item
(when only one other item is selected) the line "Item changed!"
appears THREE times instead of 2. I do not know why.
If one changes this code, taking into account the parameter pnmv:
if((pnmv->uNewState&LVNI_SELECTED)!=(pnmv->uOldState&LVNI_SELECTED))
m_wndView2.AppendText(L"Item changed!\n");
then the line "Item changed!" is printed 2 times, as expected.
But there is one problem with this message handler.
If one adds at once 100 items to selected one (via SHIFT+Left mouse click),
then OnLvnItemChanged() executes 100 times: every newly selected item
causes the execution. I will not permit to redraw rich edit pane 100 times:
texts corresponding to items of ListView can be quite large.
So I would like to have 1 single notification instead of 100.
If I could determine somehow which of these 100 notifications is the last
one in a series, I would react only on this last message. But I see no way
to catch the last message in a series. OK, there is one clumsy way:
to add a timer to CMainFrame, showing how much time is passed
after the last LVN_ITEMCHANGED message.
If this time becomes more than, say, 2ms, then
CMainFrame should update rich edit pane...
But this way is both too clumsy and too ugly.
Do there exists a more elegant way?
Stuart Dootson wrote: I suspect Michael Dunn's articles on WTL (here's the one about splitters[^]) will tell you all you need to know - I've always found them very useful!
Yes, I became acquainted with WTL reading the first articles of the series:
"WTL for MFC programmers". They really turned out to be invaluable
source of info. In spite of the fact that the last time I used MFC
was about 5--6 years ago, so I remember almost nothing about MFC
except magic words "Doc/View paradigm"
And I've used some code from later articles of the series.
In particular ListView in my program is borrowed from article VI.
I believe this will not be the last borrowing
|
|
|
|
|
Vlad0 wrote: OK, there is one clumsy way:
to add a timer to CMainFrame, showing how much time is passed
after the last LVN_ITEMCHANGED message.
If this time becomes more than, say, 2ms, then
CMainFrame should update rich edit pane...
But this way is both too clumsy and too ugly.
Do there exists a more elegant way?
That's the way I was going to suggest, until I read that you'd already thought of it
The other way might be to use PeekMessage to see if there are any pending notification messages for the frame? Alternatively - looking at the documentation:
If a list-view control has the LVS_OWNERDATA style, and the user selects a range of items by holding down the SHIFT key and clicking the mouse, LVN_ITEMCHANGED notifications are not sent for each selected or deselected item. Instead, you will receive a single LVN_ODSTATECHANGED notification, indicating that a range of items has changed state.
you could make your list-view owner data?
|
|
|
|
|
Thank You for this suggestion! WTL helper shows
this message as legal for ListView, but I had no idea,
what "ODSTAT" means, so did not made any attempts to experiment
with this.
I've just added "| LVS_OWNERDATA" to view list style.
Compiler had no objections Now I will make experiments
with LVN_ODSTATECHANGED messages instead of LVN_ITEMCHANGED.
Thank You once again!
|
|
|
|
|
You'll need to respond to LVN_GETDISPINFO[^] notifications with LVS_OWNERDATA set - but that's not too much of a hardship - it also helps if you have *a lot* of items in the list.
|
|
|
|
|
Alas WTL List View control fails to send any LVN_ODSTATECHANGED notification as well as any LVN_GETDISPINFO. I suspect
that the style flag LVS_OWNERDATA is simply ignored by
this control.
All this is very strange. One expects
that this control shold produce an "integral"
"Selection changed" event instead of
(or in addition to) "atomic" ITEMCHANGED.
As is the case with ListBox control.
The method using something like PostMessage/PeekMessage
has the same drawback, as using the series
of LBN_ITEMCHANGED with no redirection -- one is to find
a way to determine, which of the posted/picked messages is
the last one in a series.
Of course, one can write a procedure,
making an incremental update of RichEdit control
after any picked ITEMCHANGED message
(using CRichEdit.Cut()|Copy()|Paste()|SetSel()).
Incremental update may turn out to be more effective solution
than deleting all rich edit text and inserting the new one
after any "global selection changed" event. Suppose,
e.g., that one adds item 100 to 100 already
selected items -- from 0 to 99. Then incremental update
just adds Texts[100] to the end of the previous text.
Nevertheless, even while incremental update it is
more preferable to get one "global" selection change
notification instead of 100 "atomic" ones.
To guarantee that none of this 100 atomic notifications
will drop out of the message queue just because
the process of rich edit control update (even incremental one)
is much slower than the sending of a series
of notification messages.
|
|
|
|
|
Vlad0 wrote: I suspect
that the style flag LVS_OWNERDATA is simply ignored by
this control.
No - it's simply a thin wrapper over the ListView Windows control - it *does* understand LVS_OWNERDATA.
One thing...you have to set LVS_OWNERDATA when the control is created - it will ignore it if you try to set it later.
|
|
|
|
|