|
Tahnks lot RBC
Aziz Rajim
|
|
|
|
|
i am looking for some generic dll which will give me an interface to change printer settings (with out user dialog or preview) in all windows platforms (95 98 2000 NT4 and XP).. i came across some dlls which works with either one or more of the platforms but not all of them..any help finding one ? thanks
jack
|
|
|
|
|
Background: I have a MDI application that reads in a text file created by our parent company's application. The main view for the application is View subclassed from CRichEditView, I have since splitter'ed off a View subclassed from CTreeView. Therefore, when you open a document,etc, you are presented with the data from the file in the richedit view. I am then taking the data in the richedit view (ascii text), filtering and making it appear a little better. Everything up to this point is fine. When I filter the data that is being read in, I am running various searches on the text to find key words that are always in the ascii data. I am then using the CRichEditView's sibling CTreeView to "index" the keyword data. ie)lets say that the ascii data has the keyword "chk" in it 5 times. The "chk number" is always right next to the keyword "chk". I am using the TreeView to index the "chk number" and the begining line position for where that "chk number" appears (along with other keywords and positions). I then want to be able to have the user click on the "chk number" in the TreeView and automatically goto that position in the RichEditView.
Problem: I can add to the correct treeview if I update from within the treeview itself (ie, when it is constructed), but not if I call the function from another view. Here is some code.
void CEJOrganizerTreeView::OnInitialUpdate()
{
CTreeView::OnInitialUpdate();
m_ImageList.Create(IDB_SMALL_IMGLIST,16,0,RGB(0,0,0));
//GetTreeCtrl().SetImageList(&m_ImageList,TVSIL_NORMAL);
GetTreeCtrl().SetBkColor(RGB(254,239,201));
GetTreeCtrl().ModifyStyle(TVS_HASLINES,0);
GetTreeCtrl().ModifyStyle(0,TVS_HASLINES);
m_hChecks = GetTreeCtrl().InsertItem("Chks",TVI_ROOT,TVI_LAST);
// m_hChecks is a protected HTREEITEM member var
//InsertIntoChks("Test","10");
//The above works corectly when unremarked
}
bool CEJOrganizerTreeView::InsertIntoChks(CString sChkNo, CString sPosition)
//The above is predefined as a public function to access the protected members of the class
{
HTREEITEM hLast;
hLast = GetTreeCtrl().InsertItem(sChkNo,m_hChecks,TVI_LAST);
GetTreeCtrl().InsertItem(sPosition,hLast,TVI_LAST);
return true;
}
However, If I call the InsertIntoChecks function from the following code, it does not work correctly. It WILL insert into the correct treeview, but it will not insert into the the correct branch of the tree. It always posts to the TVI_ROOT.
void CEJOrganizerView::FindChks(void)
// A subclassed CRichEditView Class
{
... some initialization code...
CMainFrame* pMDIFrame = (CMainFrame*)AfxGetMainWnd();
ASSERT(pMDIFrame);
CChildFrame* pMDIChild = (CChildFrame*)pMDIFrame->MDIGetActive();
ASSERT(pMDIChild);
CEJOrganizerTreeView* pTreeView = (CEJOrganizerTreeView*) pMDIChild->m_wndSplitter.GetPane(0,0);
...some more code...
pTreeView->InsertIntoChks(sChkNo,sPosition);
...some more code...
}
My only way around this so far is to insert a new branch into the root, and then insert the "chk numbers" into that new branch, and stop the treeview fom adding the original parent items to begin with.
ie)
void CEJOrganizerView::FindChks(void)
{
... some initialization code ...
CMainFrame* pMDIFrame = (CMainFrame*)AfxGetMainWnd();
ASSERT(pMDIFrame);
CChildFrame* pMDIChild = (CChildFrame*)pMDIFrame->MDIGetActive();
ASSERT(pMDIChild);
pMDIChild->SetActiveView((CView*) pMDIChild->m_wndSplitter.GetPane(0,0)); //tried this for kicks, doesn't seem to help
CEJOrganizerTreeView* pTreeView = (CEJOrganizerTreeView*) pMDIChild->m_wndSplitter.GetPane(0,0);
HTREEITEM hCurrent = pTreeView->GetTreeCtrl().GetNextItem(pTreeView->m_hChecks,TVGN_ROOT); //using this currently, but doesn't seem to matter what is used here
//HTREEITEM hChildItem = pmyTreeCtrl->GetChildItem();
//HTREEITEM hNext = pTreeView->GetTreeCtrl().GetNextSiblingItem(hCurrent); //doesnt seem to help
HTREEITEM hChkNo;
hNext = pTreeView->GetTreeCtrl().InsertItem("Checks",TVI_ROOT,TVI_LAST);
...some more code...
hChkNo = pTreeView->GetTreeCtrl().InsertItem(sChkNo,hNext,TVI_LAST);
pTreeView->GetTreeCtrl().InsertItem(sPosition,hChkNo,TVI_LAST);
...some more code...
}
My concern is by doing it the above way, since I am not able to get to the data via my first method, am I going to be able to talk back to the CRichEditView to set the cursor position from the CTreeView? Or, will I run into a similar issue (because, even though it seems that everything is working coorectly, I am unable to get the data from the tree) when I try to make the richeditview view do something via the treeview? Hopefully, I am doing something wrong. I was hopeing to avoid sending messages from one control to another, especially since the end result is that I just need data to be moved across the two sibling views and no one else.
Thank you for any help.
|
|
|
|
|
I've come across the following code
typedef struct SEXPREC {...contents} SEXPREC, *SEXP;
Why does the name SEXPREC appear twice? The first appearance seems to be giving the struct the name and the second one the typedef. This software certainly works so it must be legal but I'm confused why it is ok to use the name twice. Can anybody explain (sorry if this is a very basic question)?
|
|
|
|
|
The first one defines the structure, the second one defines the actual typedef.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Thanks, so how is this not ambiguous when used later?
|
|
|
|
|
a common practice is to call the first one the "tag" and put "_tag" or "_t" at the end of it:
typedef struct thing_tag // or thing_t
{
...
} thing;
-c
ABSURDITY:
A statement or belief manifestly inconsistent with one's own opinion.
|
|
|
|
|
it is not ambiguous because to use the first one you have to include the struct keyword. The typedef equates "struct SEXPREC" to "SEXPREC"
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Orgasms are universal!! -- Mike Mullikin in The Lounge 21:27 15 May '02
|
|
|
|
|
Is there any know problem with CDC:: SetROP2 function?
I’m using SetROP2(R2_BLACK) to force all the lines to be drawn in black despite of the pen selected in the DC. This works fine when the plot is displayed in the screen, also in the print preview. However, if the graph is printed to a PDF file, the graph is rendered in color! I have tried with different monochrome laser printers, and in some of them the graph is plotted in pure black and white while in others it's plotted in gray-scale
Also, if I copy the graph to the clipboard as an enhanced metafile and then it is pasted in Microsoft Word (Office 2000 and XP), the graph is rendered in black and white (as I would expect) but if it's edited, the graph is converted to a colored one.
I wonder if there are compatibility issues with SetROP2, particularly with R2_BLACK mode and if there is any workaround to this problem.
Thanks in advance for your help,
Carlos
|
|
|
|
|
Hi
I have a soap method which works perfectly. The only problem is with error handling. When something wrong occurs, I return a user-defined error code, so the client can exactly figure out what went wrong.
But I return my error code, the client simply receives E_FAIL (Unexpected Error), because the class generated with "Add Web References..." only knows that the server returned a 500 HTTP error code. And if I look in the web server logs, it effectively sent back a 500 error code.
Is there a way in which I could keep the existing error handling we have? Or is there another way to do this (without having to pass extra output parameters)?
tx
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
I've already got a multiselection CListCtrl in my application. How can I set the selection through code (example: multiselect rows 1,2 and 5)?
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
TRy CListCtrl::SetItemState, with
SetItemState(nMyIndex, LVIS_SELECTED | LVIS_FOCUSED , LVIS_SELECTED | LVIS_FOCUSED);
with nMyIndex = 1, 2 and 5
|
|
|
|
|
It works invisible, but it works
If the list looses it's focus, the selection is not shown on screen (but they remain selected though). How can I set the selection visible even when the focus is transfered to another control?
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
oeps ...
Show Selection Always!!! It's as easy.
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
Yep, or programmatically with
myListCtrl.ModifyStyle(0, LVS_SHOWSELALWAYS)
HTH,
K.
|
|
|
|
|
Damn that's right ! I was wondering where it was... Just in the Styles property sheet of my control .
However I wonder how I can simply change the color to blue as if the list control still had the focus. Actually it greys the background.
Earth > Europe > France > Lyon
|
|
|
|
|
Is there any simple and clean way to add icons to a window on the fly? It seems like you have to create them and hide them is this true?
Thanks for all the help past and future.
|
|
|
|
|
Not quite sure i understand the question, but:
If you want to set the icon for a window, use SetIcon() (MFC) or WM_SETICON .
If you want to create an icon, use CreateIcon() or CreateIconIndirect() .
--------
This is what we've waited for
This is it boys, this is War! --Shog9 --
|
|
|
|
|
Hi There,
Can anyone explainme why this piece of code doesn´t work?
I'm running VC 6.0 / W2K.
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using std::string;
using std::cout;
using std::vector;
using std::ostream;
using std::endl;
class Dog {
string nm;
public:
Dog ( void ) : nm("NO NAME") {}
Dog(const string& name) : nm(name) {
cout << "Creating Dog: " << *this << endl;
}
// Synthesized copy-constructor & operator=
// are correct.
// Create a Dog from a Dog pointer:
Dog(const Dog* dp, const string& msg)
: nm(dp->nm + msg) {
cout << "Copied dog " << *this << " from "
<< *dp << endl;
}
~Dog() {
cout << "Deleting Dog: " << *this << endl;
}
void rename(const string& newName) {
nm = newName;
cout << "Dog renamed to: " << *this << endl;
}
friend ostream&
operator<<(ostream& os, const Dog& d) {
return os << "[" << d.nm << "]";
}
};
class DogHouse {
Dog* p; //Dog array
string houseName;
public:
DogHouse (Dog * lpDog, const size_t size) : p(new Dog[size]) {
memcpy(p, lpDog, size);
}
DogHouse(Dog* dog, const string& house)
: p(dog), houseName(house) {}
DogHouse(const DogHouse& dh)
: p(new Dog(dh.p, " copy-constructed")),
houseName(dh.houseName
+ " copy-constructed") {}
DogHouse& operator=(const DogHouse& dh) {
// Check for self-assignment:
if(&dh != this) {
p = new Dog(dh.p, " assigned");
houseName = dh.houseName + " assigned";
}
return *this;
}
void renameHouse(const string& newName) {
houseName = newName;
}
Dog* getDog() const { return p; }
~DogHouse() { delete p; }
friend ostream&
operator<<(ostream& os, const DogHouse& dh) {
return os << "[" << dh.houseName
<< "] contains " << *dh.p;
}
};
int main() {
Dog arrDog[2][10] = {
{ Dog("01"),Dog("02"),Dog("03"),Dog("04"),Dog("05") },
{ Dog("11"),Dog("12"),Dog("13"),Dog("14"),Dog("15") }
};
vector <DogHouse> HouseContainer;
/*HouseContainer.push_back(DogHouse(new Dog(arrDog[0]," From static array"), "Static array"));*/
HouseContainer.push_back(DogHouse(arrDog[0], sizeof(Dog)));
/*HouseContainer.push_back(DogHouse(new Dog("Kido"), "KidoHouse"));*/
std::copy(HouseContainer.begin(),
HouseContainer.end(),
std::ostream_iterator<DogHouse>(cout,"\n"));
return 1;
} ///
Assert Memory error raised when trying to do bookeeping.
I guess the problem is how static array of 'Dogs' is copied (using memcpy) to the new object 'DogHouse'.
Can anyone tell me how can I make this idea work without changing the interface, I mean I would like to keep using Dog pointer to store the array of Dog instead of a vector or other containers.
Thanks in advanced.
Carlos.
|
|
|
|
|
Can you please repost the code enabling the option "Display this message as-is (no HTML)", so that brackets appear correctly?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Even that your code made no sense as-is (due to lack of formatting and HTML "stealing" your "<" and ">" chars), the error is most definitely in your use of memcpy.
If you want to copy objects, copy objects. As a rule-of-thumb (and unless you're prepared to not being able to maintain the code yourself a short while from now), never ever memcpy a non-POD type.
Replace your DogHouse constructor (the one taking a Dog* and a size_t) with a version that really does the copy, like:
std::copy(lpDog, lpDog + size, p);
and you should at least be closer to a solution. Though, since you are already copying Dog's around here, I see no reason to not use the standard vector .
|
|
|
|
|
Never copy objects of complexed types (user defined type, ie. class, union, OOP struct, ... ) using memcpy.
Especially :
1) that contains new / delete operations for its member data.
2) a inherited one (it is derived from some kind of base class.
Please read Stanley Lippman's "Inside C++ Object Model".
Maxwell Chen
Lets make bugs better!
|
|
|
|
|
Hi There,
Thanks for the replies.
First of all, apologizes for the previous chunck of code, it was all messed up and did not make much of sense.
The reason because a wanted to keep using 'pointers' instead of a 'vector container' was because of the initialization array.
[code]
arrDog [2][5] = {
{ Dog("00"), Dog("01"), Dog("02"), Dog("03"), Dog("04"), }
{ Dog("10"), Dog("11"), Dog("12"), Dog("13"), Dog("14") }
{......}
}
[/code]
In this case initialization array is very small and could easily be changed using vector declaration.
[code]
vector <Dog> arrDog[2];
arrDog[0].push_back(Dog("00"));
arrDog[0].push_back(Dog("01"));
etc...
[/code]
Any way to avoid this anoying declaration?
In my real case, arrDog is about [100][100] and the class used isn´t as simple as Dog.
That is the only reason, just avoid rewriting all the stuff again.
I know this is a *very* poor reason, please don´t flame at me
Althought I will use vectors I have found that using std::copy instead of memcpy things seems to work a bit better.
Does anybody know the gory details of std::copy?
Does std::copy calls copy-constructors members?
Using memcpy instead of std::copy I get rubish when printing stuff saved in vectors but I don´t get memory error, any reason?
[code]
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using std::string;
using std::cout;
using std::vector;
using std::ostream;
using std::endl;
class Dog {
string nm;
public:
Dog ( void ) : nm("NO NAME") {}
Dog(const string& name) : nm(name) {
cout << "Creating Dog: " << *this << endl;
}
Dog(const Dog& d) : nm("copy " + d.nm) {
cout << "Copy-constructed Dog " << nm << endl;
}
~Dog() {
cout << "Deleting Dog: " << *this << endl;
}
friend ostream&
operator<<(ostream& os, const Dog& d) {
return os << "[" << d.nm << "]";
}
};
class DogHouse {
Dog * m_p; //Dog Array
int m_n; //Number of dogs
string m_houseName;
public:
DogHouse (const Dog * p, const int n , const string& hn)
: m_p(new Dog[n * sizeof(Dog)]) ,m_n (n), m_houseName(hn) {
std::copy(p, p + n, m_p);
//memcpy(m_p, p , n * sizeof(Dog)); Uncomment this
}
DogHouse(const DogHouse& dh)
: m_p(new Dog[dh.m_n * sizeof(Dog)]), m_n(dh.m_n),
m_houseName(dh.m_houseName + " copy-constructed") {
std::copy(dh.m_p,dh.m_p+dh.m_n,m_p);
//memcpy(m_p, dh.m_p, dh.m_n * sizeof(Dog)); Uncomment this
}
~DogHouse() { delete [] m_p; }
friend ostream&
operator<<(ostream& os, const DogHouse& dh) {
os << "[" << dh.m_houseName << "] contains " << endl;
std::copy(dh.m_p,dh.m_p + dh.m_n,
std::ostream_iterator<Dog>(os,"\n"));
return os;
}
};
int main() {
Dog arrDog[4][5] = {
{ Dog("01"),Dog("02"),Dog("03"),Dog("04"),Dog("05") },
{ Dog("11"),Dog("12"),Dog("13"),Dog("14"),Dog("15") },
{ Dog("21"),Dog("22"),Dog("23"),Dog("24"),Dog("25") },
{ Dog("31"),Dog("32"),Dog("33"),Dog("34"),Dog("35") }
};
vector <DogHouse> HouseContainer;
HouseContainer.push_back(DogHouse(arrDog[0], 5 ," Dog Row 0 "));
HouseContainer.push_back(DogHouse(arrDog[1], 5 ," Dog Row 1 "));
HouseContainer.push_back(DogHouse(arrDog[3], 5 ," Dog Row 3 "));
std::copy(HouseContainer.begin(),
HouseContainer.end(),
std::ostream_iterator<DogHouse>(cout,"\n"));
return 1;
}
[/code]
Regards
Carlos.
|
|
|
|
|
Your choice for the global array is perfectly valid since it's a compile-time static set, no need to use a vector here.
However, I think you'd be better off to make the Dog array m_p inside doghouse a standard container. It would make your code easier to maintain, it would take care of all resource management, and (unless you really wanted to) it would allow you to use the compiler generated versions of copy-contructor, assignment operator and destructor.
Does anybody know the gory details of std::copy?
Yes, and so do you if you look it up in the documentation or even the header files. It's defined by including <algorithm>. If you're using the Dinkum library it's acually defined in <xutility>, though you are only to get to its definition using <algorithm>. It's basically a copy loop.
|
|
|
|
|
Hi,
I am looking to code a method to record audio in a suitable compressed format comaparable to radio quality, with the minimum amount of fuss.
Can someone point me in the right direction? Which libraries and codecs etc.
Thanks,
Richard
|
|
|
|
|