|
hi,
i got example for BHO from MSDN. it is atl com. it is creating dll and registor in the BHO registry. once it is registor, automaticaly is invoked when the IE starts. it is using setsite method. it is getting html code of the page. But i want to get the POST data of form. pls guid me how to do this. if you know any article about this pls mail me.
|
|
|
|
|
I have an application where I have the usual MainFrame (as so kindly provided by the WTL wizard) but also a copy&paste of that under another name.
I have created a separate toolbar resource for the new frame window but if I specify UPDUI_TOOLBAR for any of the IDs used in that toolbar, the application crashes during PeekMessage() in CMessageLoop::Run().
If I just specify 0 (zero) instead, everything works fine except UISetCheck() for any of the buttons in the second toolbar does nothing.
What to do?
Thanks.
|
|
|
|
|
is there any way of sorting a list with a custom function? i'm trying to sort a list of pointers to structs, so the list.sort() method doesn't work.
-thanks
|
|
|
|
|
Depends - either you can overload operator < at the contained object or, if your stl implementation allows it, you can use the customized sort functor.
The list's sort function should be defined as follows:
void sort(greater<T> pr);
therefore you can define your own:
<br />
struct ptrSort : public greater<SortMe*> <br />
{<br />
bool operator()(const SortMe* &p1, const SortMe* &p2) const<br />
{ <br />
return p1->m_ember < p2->m_ember; <br />
}<br />
};<br />
and use it
list.sort( ptrSort() );
Hope that helps
|
|
|
|
|
Hi geo_m, thanks for the reply. unfortunately i can't get it to work
it compiles ok but doesn't seem to actually use the customized sort functor. i put a call to MessageBox() inside ptrSort
struct ptrSort : public greater<SortMe*>
{
bool operator()(const SortMe* &p1, const SortMe* &p2) const
{ MessageBox(g_hMainWnd, "inside ptrSort", "", 0);
return p1->m_ember < p2->m_ember;
}
};
but no message boxes ever show up, and the list is sorted exactly the same way as if i used list.sort(greater<sortme*>()) instead of list.sort( ptrSort() ) )
any idea whats going wrong?
-thanks
|
|
|
|
|
I see. Look at KB265109
BUG: The STL list::sort() Function Doesn't Sort a List of Pointers
This could help you to point into the right direction
|
|
|
|
|
i got it to work, thank you!
|
|
|
|
|
After hours of searching I finally found a solution being described by "DerMeister" in a post in the following forum (scroll down to post from 5/31/2003):
http://www.gamedev.net/community/forums/topic.asp?topic_id=159921
To quote him (1st example would be "best" in STL but 2nd example does work with Visual C++ 6.0):
[QUOTE]
At last!!! I found the way around it... I suggest anyone using VC 6 to read this. First I found that the "right" way to work with sorting STL lists is not supported by MSVC6.
With the right way I mean for example:
using namespace std;
struct compareByRS
{
bool operator()(const C3DObject* obj1, const C3DObject* obj2)const
{ return (obj1->rs) < (obj2->rs);}
};
list<c3dobject*> ObjsList;
//then I insert a few pointers to the list with random values in //the rs member (an int)
lst.sort(compareByRS()); //this would sort by rs
but, for the MS guys something should be done their way:
template<>
bool std::greater<c3dobject*>::operator()(C3DObject* const& p1, C3DObject* const& p2) const
{
return p1->rs < p2->rs;
}
list<c3dobject*> ObjsList
//I fill the list the same way
ObjsList.sort(greater<c3dobject*>());
//and use this horrible way to sort it... that's the MS way...
Anyway changing < to > sets the way to sort the list... I hope this is the only exception to work with STL under MSVC (which I doubt)...
Thanks to all who helped...
No matter where you go... &this
[/QUOTE]
gosh, you don't know how happy I am now ))
Bye,
T.T.H.
|
|
|
|
|
Currently writing a memory management system and I decided it'd be the logical thing to use stl maps to store various data. I'm very new to stl so I don't really understand the ins and outs of it yet, so I'm stuck on a problem which *should* be easy, but I'm doing something wrong.
I'm basically keeping a map of maps, with a unique string as the key to each of the maps. Here's one of my insert functions:
bool CHeapStore::_insert (heapHeader_t *header) {
map<int, heapHeader_t *> tmpMap;
pair< map<string, map<int, heapHeader_t *> >::iterator, bool> p;
tmpMap.insert(pair<int, heapHeader_t *>(header->id, header));
p = s_heaps.insert(pair<string, map<int, heapHeader_t *> >(header->name, tmpMap));
s_mmStashing = false;
return p.second == true ? true : false;
}
The program crashes on the s_heaps.insert() and returns the debugger to this in xtree:
_Pairib insert(const value_type& _Val)
{ // try to insert node with value _Val
_Nodeptr _Trynode = _Root(); // crashes here
What am I doing wrong? I've also tried other insertion methods, but this is the most direct one. The s_heap is an empty map when it crashes, it's the first call to the insert function.
Thank you so much for any help. btw, i'm using the default stl library that comes with MSVC .NET 2003.
-j
|
|
|
|
|
If you are using a map of maps and don't care about existence before inserting (you are willing to overwrite values if the keys match) then try the following:
declaration: map < string , map < int , heapHeader_t* > > storage.
To insert, just use the subscripts for access. If the items does not exist in the map, the map will automatically insert the item using the keys from the
subscripts.
storage[string][int] = headHeader_t* item;
But removing items from the map is different question.
Hopefully this is helpful.
Glenn
|
|
|
|
|
I converted your code into a small test program,
#include <map>
#include <string>
struct heapHeader
{
std::string name_ ;
int id_ ;
void * p_ ;
} ;
struct heap
{
std::map<std::string, std::map<int, heapHeader *> > s_heaps ;
bool insert ( heapHeader *header)
{
std::map<int, heapHeader *> tmpMap;
std::pair< std::map<std::string, std::map<int, heapHeader *> >::iterator, bool> p;
tmpMap.insert(std::pair<int, heapHeader *>(header->id_, header));
p = s_heaps.insert(std::pair<std::string, std::map<int, heapHeader *> >(header->name_, tmpMap));
return p.second ;
}
} ;
int main( )
{
heap h ;
heapHeader * ph = new heapHeader ;
ph->id_ = 0 ;
h.insert ( ph ) ;
return 0;
}
and it compiles and runs as expected. So I don't know what your problem is.
However I think your code is wrong. In the first place I wouldn't use a map where the key is embedded in the type, a set would be more efficient, you can create specific predicates to allow the object to be sorted according to its id or name. Secondly what if you insert a subsequent heapHeader with the same name? I assume this is legal? This way your maps of id-heapheader would have more than one member.
Anyway I would consider rewriting 'insert' along these lines,
void insert ( heapHeader *header)
{
std::pair< std::map<std::string, std::map<int, heapHeader *> >::iterator, bool> ;
p = s_heaps.insert(std::make_pair<std::string, std::map<int, heapHeader *> >(header->name_, std::map<int, heapHeader *> ()));
(*p.first).second.insert ( std::make_pair ( header->id_, header )) ;
}
Although perhaps the syntax could be tidied. The point is that std::map::insert never fails (other than through memory exhaution, in which case it throws an exception), it either inserts a new entry and returns 'true' in the second part of the pair, or returns false. In either case the first part of the return is an iterator to the appropriate entry.
Hope that made some sense.
Paul
|
|
|
|
|
Hi I am trying to extract image data from a binary file. I am new to
java and I am using eclipse in windows 2000.
there are a total of 9 images in the file out of which i am extracting
8.the images are littleendian.
The program always displays the last image. if i change
NUMOFIMAGES to 2 then it displays img[2] and if it is 7 displays
img[7] for all the images; Any ideas on this?
<br />
import java.io.*;<br />
import javax.swing.*;<br />
import java.awt.*;<br />
import java.awt.event.*;<br />
import java.awt.image.*;<br />
<br />
public class scanner3d extends JPanel {<br />
static Image img[] = new Image[10];<br />
<br />
public static void main(String[] args) throws IOException {<br />
scanner3d scner = new scanner3d();<br />
int WIDTH = 150;<br />
int HEIGHT = 200;<br />
int NUMOFIMAGES = 9;<br />
<br />
<br />
try {<br />
File file = new File("c:\\java\\15");<br />
FileInputStream fileInput = new FileInputStream(file);<br />
LEDataInputStream ledatainputstream =<br />
new LEDataInputStream(fileInput);<br />
float data[][][] = new float[NUMOFIMAGES][HEIGHT][WIDTH];<br />
float max = 0;<br />
for (int m = 0; m < NUMOFIMAGES; m++) {<br />
for (int k = 0; k < HEIGHT; k++) {<br />
for (int j = 0; j < WIDTH; j++) {<br />
float in = ledatainputstream.readFloat();<br />
if (in < 0)<br />
in = 0;<br />
if (in > max)<br />
max = in;<br />
data[m][k][j] = in; <br />
}<br />
}<br />
}<br />
int OneDimImage[] = new int[WIDTH * HEIGHT];<br />
<br />
for (int m = 0; m < NUMOFIMAGES; m++) {<br />
for (int k = 0; k < HEIGHT; k++) {<br />
for (int j = 0; j < WIDTH; j++) {<br />
int temp = (int) (data[m][k][j] / max * 255);<br />
int col = (255 << 24) | (temp << 16) | 0;<br />
OneDimImage[k * WIDTH + j] = col;<br />
}<br />
}<br />
img[m] =<br />
java.awt.Toolkit.getDefaultToolkit().createImage(<br />
new MemoryImageSource(<br />
WIDTH,<br />
HEIGHT,<br />
OneDimImage,<br />
0,<br />
WIDTH));<br />
<br />
<br />
}<br />
<br />
JFrame f = new JFrame();<br />
f.addWindowListener(new WindowAdapter() {<br />
public void windowClosing(WindowEvent e) {<br />
System.exit(0);<br />
}<br />
});<br />
f.getContentPane().add(scner);<br />
f.show();<br />
} catch (Exception r) {<br />
System.out.println(r);<br />
System.exit(0);<br />
}<br />
}<br />
public void paint(Graphics g) {<br />
super.paint(g);<br />
Dimension d = getSize();<br />
Insets i = getInsets();<br />
g.drawImage(img[0], 13, 15, 245, 190, this);<br />
g.drawImage(img[1], 263, 15, 245, 190, this);<br />
g.drawImage(img[2], 513, 15, 245, 190, this);<br />
g.drawImage(img[3], 763, 15, 245, 190, this);<br />
g.drawImage(img[4], 13, 211, 245, 190, this);<br />
g.drawImage(img[5], 263, 211, 245, 190, this);<br />
g.drawImage(img[6], 513, 211, 245, 190, this);<br />
g.drawImage(img[7], 763, 211, 245, 190, this);<br />
}<br />
}
Have Fun!!!
|
|
|
|
|
I'm using CSMTPConnection (ATL) in a send-mail program.
The mail server at the other end requires authentication. How do I get authentication using the CSMTPConnection class? Or do I have to use some other class?
|
|
|
|
|
You can't do it directly with CSMTPConnection . I suggest looking at "CDO for Windows 2000" (CDOSYS).
You could write the necessary extra code for CSMTPConnection ; the specifications are in RFC 2821[^] for SMTP itself, and RFC 2554[^] for the AUTH extension.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hi respected ATL/WTL/STL people,
I need your heeeeeeeelp at once.
1. Tell me, or send me a good wtl tutorial, especially if it contains a comparison between usage of MFC and WTL.
or
2. If this look shorter and easier for u, first listen to this and then send me needed answers
I need to convert a program from MFC to WTL.
2.1.
How should I write this MFC code:
SetFont(GetStockFont(DEFAULT_GUI_FONT));
in WTL ?
It always tells me:
error C3861: 'GetStockFont': identifier not found, even with argument-dependent lookup
2.2.
What about this? :
CWnd* pWndOwner = GetOwner();
How should THIS ^ MFC line be written in WTL ?
2.3.
What does this means and what should I do if it writes to me:
error C3861: 'ASSERT': identifier not found, even with argument-dependent lookup
That's it
Would you be so kind to help me out with this?
Please send me the answer for me first and/or my second question at my e-mail: vuchko_@hotmail.com
Thank you very much for your help and for your time
Greatfull
Ajnstajn
|
|
|
|
|
Ajnstajn wrote:
1. Tell me, or send me a good wtl tutorial
Check out Michael Dunn's excelent series of "WTL for MFC Programmers" articles http://codeproject.com/wtl/wtl4mfc1.asp[^]
Ajnstajn wrote:
GetStockFont(DEFAULT_GUI_FONT));
You could try AtlGetStockFont(DEFAULT_GUI_FONT); If you look at it's source in atlmisc.h, you see that it's just a wrapper for ::GetStockObject()
Ajnstajn wrote:
2.2.
What about this? :
CWnd* pWndOwner = GetOwner();
How should THIS ^ MFC line be written in WTL ?
Well looking at the MFC source (it's always a good thing to install the MFC source when installing devstudio - you'll never know what you'll learn) CWnd::GetOwner looks like this
_AFXWIN_INLINE CWnd* CWnd::GetOwner() const
{ return m_hWndOwner != NULL ? CWnd::FromHandle(m_hWndOwner) : GetParent(); }
Depending on your situation, you could probably replace it with someing like
CWindow wndOwner = GetParent() . Presuming that you are in a CWindow object
Ajnstajn wrote:
'ASSERT': identifier not found
Use ATLASSERT
But seriously, check out Michael Dunn's articles, there all found in the WTL section here on CodeProject http://codeproject.com/wtl/index.asp#Beginners[^] You'll learn a lot.
[ Jason De Arte | Toy Maker | 1001010.com ]
|
|
|
|
|
|
with API use CreateFile , with traditional C++ use std::fstream
-Derick
|
|
|
|
|
Hai all,
I have a basic doubt when to use the Composite Design Pattern and When to use the Builder Design Pattern.
Do anyone explain me its difference with a scenario.
With Thanks,
Arun Chakaravarthy
|
|
|
|
|
You are referring to interface based design and template based design, correct?
COM is based on interface based design (composite) as an object and its type is only exist at runtime.
Template based design (builder) is known at compile-time.
Kuphryn
|
|
|
|
|
LPDRAWITEMSTRUCT lpdis;
In an Ownerdrawn menu handler WindowFromDC(lpdis->hDC) always return zero?
Any clues?
Thanks,
Derick.
|
|
|
|
|
And it always will.
HMENU's are the resource of a window - and never a true user accessable window themselves. It has something to do with the way that windows internally deals with menus - somehow that bit of geek trivia is lost to me & forgotten.
But I wouldn't wory about it, if you're doing an owner draw menu - all you need is the HDC anyways. If you need dimensions of the full menu for a side bar or something, I'd check out the multiple ownerdraw menu samples here on codeproject.
[ Jason De Arte | Toy Maker | 1001010.com ]
|
|
|
|
|
But I think I found the problem. It has something to do with mwnu animation. for animation purpouse, widows supplies another dc. This is what i think happens with a context menu.
-Derick
|
|
|
|
|
please help me .i wonder if the WTL is only used for the VC?
|
|
|
|
|
I 'am (beginner) in program ATL 7.0. I have made a ActiveX-control (with DirectX drawing a cruve,ATLserver, DLL) DirectX drawn also its own background. The control will be created with "CAxWindow"->CreateControl in the client window.
The problem is that the control first draw the background color and then DirectX draw also secondly its own background and the curve. I have tryed with WM_ereaseBkgnd (in ATL DLL) to prevent the first drawing background, but the routine will not be called.
Also the WM_ereaseBKgnd on the client side will not be called.
I don't know how prevent background drawing?
Theon
|
|
|
|
|