|
I think I've found the problem. CList doesn't provide a copy or an assignement operater witch is needed. So it is not possible to store a clist or a carray within a clist or a carray. But this is what i need!
|
|
|
|
|
Hi there.
I am creating a CEdit control using Create method. In that i am specifying the control to be right aligned. It works fine with Win NT. But, it turns centre aligned in Wnidows 95. It works properly in 98 also.
Please let me know if anybody knows the solution.
Thanx.
- Amit Engineer.
|
|
|
|
|
I am using StretchBlt to make a mirror image of the page.
While the normal page prints on when I try to use StretchBlt on this StretchBlt always return 1 but prints nothing. Pl. Help Me!. I am embeding the source func.
/* --------------------------------------------------- */
void CTprView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
int top,left,right,bottom;
RECT rt ;
pDC->SetMapMode (MM_ANISOTROPIC) ;
PrDC.SetMapMode (MY_MODE) ; // this is the CreatIC of the default printer driver
pDC->SelectObject (&pen) ;
PrDC.SelectObject (&pen) ;
top = TopMargin ;
left = (int)((LeftMargin * hPixPerMM) - (int)(hPixPerMM/1.5));
right = (int)((ColWith * 3.00) + (Gutter * 2.00) + (hPixPerMM * 1.5)) ;
bottom = (int)(vPixPerMM * m_PgLn);
if (m_mirror != TRUE) {
PreparePages (pDC, pInfo) ;
TestPage (pDC, pInfo) ;
} else {
MirrorDC.CreateCompatibleDC(pDC);
MirrorDC.SetMapMode (MY_MODE) ;
MirrorDC.SetTextColor (RGB (0,0,0));
MirrorDC.SetViewportOrg (0, 0) ;
MirrorDC.SetWindowOrg (0, 0) ;
PreparePages (&MirrorDC, pInfo) ; // if pages=1 then calculates pages into a CTypedPtrArray
TestPage (&MirrorDC, pInfo) ; // draws text,bitmaps & lines on the CDC provided
if (!IsInCalc) {
rt.top = top ;
rt.left = left;
rt.right = right;
rt.bottom = bottom;
PrDC.DPtoLP (&rt) ;
top=pDC->StretchBlt(left,top,right,-bottom,&MirrorDC,left,top,right,bottom,SRCCOPY);
CString cTmp ;
cTmp.Format("Ret. Value = %d", top) ;
MessageBox (cTmp, "S.Blt", MB_OK) ;
}
MirrorDC.DeleteDC ();
}
}
|
|
|
|
|
this is certainly beyond my knowledge to learn that array[-1] is valid in some cases.
i am shocked, stunned and desparate !
i am now examing an existing project and i am suspecting this is the cause of all evils.
but now somebody said this is perfectly legal.
okay okay..
let me draw the picture bigger.
there is this array of struct defined like this..
struct someStruct array[100] and i am assigning like this
array[-1].field1 = something.
so so..is this so called access the return address or read parameter directly ??
arghhh !!! what am i talking about ?? some1 pls resurrect me !!
|
|
|
|
|
It's my understanding that a[i] is identically equivalent to *(a + i). No restriction is made on the sign of i, so array[-1] is syntactically fine.
However, in your code example:
struct someStruct array[100];
array[-1].field1 = something;
That is accessing outside the bounds of the array. Bad move. It's just as bad as doing "array[2000].field1=xyz;"
|
|
|
|
|
<br />
It would only be useful in a small number of cases.<br />
<br />
Say, if you wrote a peice of code like this:<br />
<br />
char text[100];<br />
char *ref = text[1];<br />
if(*ref == ref[-1]) return FIRST_EQUALS_SECOND;<br />
<br />
However, I don't see why you would want to do that in any normal case.<br />
==================
The original message was:
this is certainly beyond my knowledge to learn that array[-1] is valid in some cases. i am shocked, stunned and desparate ! i am now examing an existing project and i am suspecting this is the cause of all evils. but now somebody said this is perfectly legal. okay okay.. let me draw the picture bigger. there is this array of struct defined like this.. struct someStruct array[100] and i am assigning like this array[-1].field1 = something.
so so..is this so called access the return address or read parameter directly ?? arghhh !!! what am i talking about ?? some1 pls resurrect me !!
|
|
|
|
|
I have an INF file with the following sections in it:
[Version]
Signature="$Windows NT$"
Provider=Gooroos Software
[Install]
CopyFiles=CopyFiles
[CopyFiles]
file1
[DestinationDirs]
CopyFiles=11 ; Same as %windir%\system32
[SourceDiskNames]
1="Installation"
[SourceDiskFiles]
file1=1
I can use this INF to install file1 just fine. However, if I try to create a disk space list for the Install section, I get an error. I.e:
SetupAddInstallSectionToDiskSpaceList(diskSpaceList, m_hInf, 0, "Install", 0, 0);
fails and GetLastError() returns a code of -536870654.
If I change the section name from "Install" to "CopyFiles", then the call succeeds, but when I query the drive list I get back an empty string. I.e:
SetupQueryDrivesInDiskSpaceList(diskSpaceList, NULL, 0, &driveListSize)
returns a list size of 1 character (i.e. just the terminating null byte).
Obviously I'm doing something wrong, so does anyone have an example of using a disk space list which actually works?
Thanx.
|
|
|
|
|
I've written a Developer Studio 6.0 add-in which changes the project's linker settings using AddToolSettings() and RemoveToolSettings().
Although my changes immediately appear in the Project->Settings windows, none of the Build commands will use the new settings until after I have closed and reopened the
workspace. Not even doing a Build->Clean helps.
Anyone know of a programmatic way of forcing the Build commands to pick up my changes?
Thanx.
|
|
|
|
|
Does anybody knows how to integrate CVS version control with the Visual Devstudio IDE? My company is migrating there right now(BIG mistake), so I am trying to find a civilized way to work with it instead of the command line or WinCVS things... Is there any addin available?
|
|
|
|
|
Currently there is no real CVS support
for VC++
the only project that I know if doing something like this is
http://members.home.net/preston/cvsscc.html
and they're not even close to being done.
might i offer bitkeeper(out RSN) www.bitkeeper.com, it will integrate into VC++
==================
The original message was:
Does anybody knows how to integrate CVS version control with the Visual Devstudio IDE? My company is migrating there right now(BIG mistake), so I am trying to find a civilized way to work with it instead of the command line or WinCVS things... Is there any addin available?
|
|
|
|
|
You may want to have a look at CS-RCS which is based on GNU RCS and integrates with VC++. Their site is http://www.componentsoftware.com/
Neville Franks - Author of ED for Windows
www.getsoft.com
==================
The original message was:
Does anybody knows how to integrate CVS version control with the Visual Devstudio IDE? My company is migrating there right now(BIG mistake), so I am trying to find a civilized way to work with it instead of the command line or WinCVS things... Is there any addin available?
|
|
|
|
|
How to change mouse cursor to "IDC_IBEAM" when move mouse pass the button?
This is my easy win32 code, please edit or modify this code below. Thank you.
#include "afxwin.h"
#define IDC_BUTTON1 100
class CApp:public CWinApp{
public:
virtual BOOL InitInstance();
};
CApp app;
class CWin:public CFrameWnd{
CButton *button;
public:
CWin();
~CWin();
};
BOOL CApp::InitInstance(){
m_pMainWnd=new CWin();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
};
CWin::CWin(){
Create(NULL,"Hello",
WS_OVERLAPPEDWINDOW,CRect(0,0,200,200));
button=new CButton();
button->Create("OK",
WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
CRect(50,50,100,100),this,IDC_BUTTON1);
}
CWin::~CWin(){
delete button;
}
|
|
|
|
|
Don't quote me on this BUT I think you could try setting the cursor using SetCursor in OnSetCursor - WM_SETCURSOR.
|
|
|
|
|
There are two possible ways of implementing this (that I know of). Both of them include trapping either one or both of the MOUSEMOVE or SETCURSOR messages.
You can either trap them at level of the main FrameWnd or in the Button (I would personally prefer to subclass the Button and trap it in there so I could reuse that new button in other parts of my code). In the case of trapping it in the FrameWnd (probably trapping MOUSEMOVE after you know the cursor is in the FrameWnd - using SETCURSOR to set some flag) you then need to work out if the mouse is over the button to change to the IBEAM cursor - as well as not over the button to change it back!!).
There are probably other pitfalls to worry about that my simple explanation doesn't cover but they would be the two basic approaches to consider.
Regards,
Gary Menzel
==================
The original message was:
How to change mouse cursor to "IDC_IBEAM" when move mouse pass the button?
<cut>
|
|
|
|
|
I developed a dll with a class exported. In my application, I declare an object of it and call one of its member functions. I got the following link time error:
error LNK2001: unsolved external symbol "__declspec(dllimport) public:void __thiscall testclass::function(char const *)" (__imp_?Export@testclass@@QAEXPBD@Z)
When I look at the dll, I see
...
314 139 00001131 ?function@testclass@@QAEXPBG@Z
Apparently there is a mismatch here. I would like to know the reason of this problem. Any ideas?
|
|
|
|
|
Hi!
You have to declare the class as "__declspec(dllimport)". And you also have to include the *.LIB file for your DLL. You can do this in the Link section of your project settings or by inserting the pragama in the source code. For example:
#pragma comment(lib, "MyClass.lib")
Regards,
Alex Gorev,
Dundas Software.
==================
The original message was:
I developed a dll with a class exported. In my application, I declare an object of it and call one of its member functions. I got the following link time error: error LNK2001: unsolved external symbol "__declspec(dllimport) public:void __thiscall testclass::function(char const *)" (__imp_?Export@testclass@@QAEXPBD@Z)
When I look at the dll, I see
... 314 139 00001131 ?function@testclass@@QAEXPBG@Z
Apparently there is a mismatch here. I would like to know the reason of this problem. Any ideas?
|
|
|
|
|
How could I make status bar to show tool tips for its panes?
Regards,
Stefan
----------
|
|
|
|
|
Stefan,
If the items in your status bar have ID's, then you can add them to a tooltip object like so:
CWnd* pSomeItem = GetDlgItem(IDC_SOMEID);
m_tooltip.Create(this);
m_tooltip.Activate(TRUE);
m_tooltip.AddTool(&pSomeItem, "A tool tip");
Then, in your mainframe do the following:
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
// Let the ToolTip process messages.
m_tooltip.RelayEvent(pMsg);
return CMDIFrameWnd::PreTranslateMessage(pMsg);
}
This might work.
==================
The original message was:
How could I make status bar to show tool tips for its panes?
Regards, Stefan ----------
|
|
|
|
|
Have you tried:
SendMessage
(
hStatusBarWnd,
SB_SETTIPTEXT,
(WPARAM)(INT)iStatusBarPart,
(LPARAM)(LPCTSTR)lpcszTextToDisplayAsTooltip
);
code sequence?
The status bar window must be created (as in the following example) using
g_hStatusBarWnd =
CreateWindowEx
(
0L,
STATUSCLASSNAME,
0,
WS_CHILD | WS_VISIBLE | SBT_TOOLTIPS,
0,
0,
0,
0,
hParentWnd,
(HMENU)ID_STATUSBAR,
g_hInstance,
0
);
For more information, you can check the WindowsNT System Manager, where you can find, among other stuff like this, also something about status bar APIs.
All the best,
Sardaukar
==================
The original message was:
How could I make status bar to show tool tips for its panes?
Regards, Stefan ----------
|
|
|
|
|
Hi,
does anyone know how to to fnd out whether a string matches a wildcard pattern? Something like
int iMatch = wcmatch("??ES*H", "DOESMATCH");
There are lots of functions that use wildcards on filenames or database tables - but I didn' find anything for strings.
Any ideas or sample code welcome!
|
|
|
|
|
Hi
I don't know any existing function which can
do this but it's very easy to write it yourself.
Here is the fully working example:
bool strmatch(char *lpszWildCard, char *lpszString)
{
if(lpszWildCard == NULL || lpszString == NULL) {
return false;
}
while(*lpszWildCard != NULL && *lpszString != NULL) {
if(*lpszWildCard == '?') {
}
else if(*lpszWildCard == '*') {
++ lpszWildCard;
while(*lpszWildCard != *lpszString && *lpszString != NULL) {
++lpszString;
if(*lpszWildCard == NULL || *lpszString == NULL)
break;
}
}
else if(*lpszWildCard != *lpszString) {
return false;
}
++ lpszString;
++ lpszWildCard;
}
if(*lpszString == NULL) {
while(*lpszWildCard == '*') {
++lpszWildCard;
}
}
if(*lpszWildCard == *lpszString) {
return true;
}
return false;
}
Let me know if you have any problems with this code.
Alex Gorev,
Dundas Software.
==================
The original message was:
Hi, does anyone know how to to fnd out whether a string matches a wildcard pattern? Something like int iMatch = wcmatch("??ES*H", "DOESMATCH"); There are lots of functions that use wildcards on filenames or database tables - but I didn' find anything for strings. Any ideas or sample code welcome!
|
|
|
|
|
Hi Alex,
thanks for your code. It is ok for the most cases. But there are many cases in which strmatch() will fail:
strmatch("*?s*", "doesmatch");
doesn't work, because after '*' explicit match to '?' is searched.
strmatch("*to*", "doesmatchtoo");
doesn't work because '*t' finds the first 't' and compares "tchtoo" with "to*" - result: no match.
Due to a bug in the '*' case, the function will return false on all wildcards, that end on '*':
else if(*lpszWildCard == '*')
{
++ lpszWildCard;
while(*lpszWildCard!=*lpszString && *lpszString!=NULL)
{
++lpszString;
// this is WRONG
//if(*lpszWildCard == NULL || *lpszString == NULL)
// break;
// must be like this:
if(*lpszWildCard == NULL)
return TRUE; // rest DOES match to '*'!
if (*lpszString == NULL)
break;
}
}
I suppose, that a 100% solution requires recursion and is NOT so easy to realize!
-- Thomas
==================
The original message was:
Hi
I don't know any existing function which can do this but it's very easy to write it yourself.
Here is the fully working example:
bool strmatch(char *lpszWildCard, char *lpszString) { if(lpszWildCard == NULL || lpszString == NULL) { return false; }
while(*lpszWildCard != NULL && *lpszString != NULL) { if(*lpszWildCard == '?') { } else if(*lpszWildCard == '*') { ++ lpszWildCard; while(*lpszWildCard != *lpszString && *lpszString != NULL) { ++lpszString; if(*lpszWildCard == NULL || *lpszString == NULL) break; } } else if(*lpszWildCard != *lpszString) { return false; }
++ lpszString; ++ lpszWildCard; }
if(*lpszString == NULL) { while(*lpszWildCard == '*') { ++lpszWildCard; } }
if(*lpszWildCard == *lpszString) { return true; }
return false; }
Let me know if you have any problems with this code.
Alex Gorev, Dundas Software.
================== The original message was: Hi, does anyone know how to to fnd out whether a string matches a wildcard pattern? Something like int iMatch = wcmatch("??ES*H", "DOESMATCH"); There are lots of functions that use wildcards on filenames or database tables - but I didn' find anything for strings. Any ideas or sample code welcome!
|
|
|
|
|
Hi Thomas!
Of course my example will not work correctly in many situations,
I've spend about 5 minutes writing it and my main task was to give
an idea how you can do this.
If you really want to make something like this you should spend much
more time coding and testing. You've mention about the recursion but
I don't think it's the right place for it, the only place when you can use
it
is while testing for the '*' but I don't see big advantage comparing to the
usual loop.
So spend some time, add several IFs and WHILEs and it will work great
for you. And don't try to find an existing function, it's always better to
do something small like this yourself, because you can always adjust it
to your own needs.
Don't forget to post the results on the CodeProject and I will also took
part in testing...
Regards,
Alex Gorev,
Dundas Software.
==================
The original message was:
Hi Alex,
thanks for your code. It is ok for the most cases. But there are many cases in which strmatch() will fail:
strmatch("*?s*", "doesmatch"); doesn't work, because after '*' explicit match to '?' is searched.
strmatch("*to*", "doesmatchtoo"); doesn't work because '*t' finds the first 't' and compares "tchtoo" with "to*" - result: no match.
Due to a bug in the '*' case, the function will return false on all wildcards, that end on '*':
else if(*lpszWildCard == '*') { ++ lpszWildCard; while(*lpszWildCard!=*lpszString && *lpszString!=NULL) { ++lpszString; // this is WRONG //if(*lpszWildCard == NULL || *lpszString == NULL) // break; // must be like this: if(*lpszWildCard == NULL) return TRUE; // rest DOES match to '*'! if (*lpszString == NULL) break; } }
I suppose, that a 100% solution requires recursion and is NOT so easy to realize!
-- Thomas ================== The original message was: Hi
I don't know any existing function which can do this but it's very easy to write it yourself.
Here is the fully working example:
bool strmatch(char *lpszWildCard, char *lpszString) { if(lpszWildCard == NULL || lpszString == NULL) { return false; }
while(*lpszWildCard != NULL && *lpszString != NULL) { if(*lpszWildCard == '?') { } else if(*lpszWildCard == '*') { ++ lpszWildCard; while(*lpszWildCard != *lpszString && *lpszString != NULL) { ++lpszString; if(*lpszWildCard == NULL || *lpszString == NULL) break; } } else if(*lpszWildCard != *lpszString) { return false; }
++ lpszString; ++ lpszWildCard; }
if(*lpszString == NULL) { while(*lpszWildCard == '*') { ++lpszWildCard; } }
if(*lpszWildCard == *lpszString) { return true; }
return false; }
Let me know if you have any problems with this code.
Alex Gorev, Dundas Software.
================== The original message was: Hi, does anyone know how to to fnd out whether a string matches a wildcard pattern? Something like int iMatch = wcmatch("??ES*H", "DOESMATCH"); There are lots of functions that use wildcards on filenames or database tables - but I didn' find anything for strings. Any ideas or sample code welcome!
|
|
|
|
|
Hi Thomas,
Try this method, maybe it will work correctly:
bool strmatch(char *lpszWildCard, char *lpszString)
{
if (lpszWildCard == NULL || lpszString == NULL)
return false;
char *p;
if ((p = strpbrk(lpszWildCard, "?*")) == NULL)
return 0 == strcmp(lpszWildCard, lpszString);
if (0 != strncmp(lpszString, lpszWildCard, p - lpszWildCard))
return false;
lpszString += p - lpszWildCard;
if (*p == '?')
return (*lpszString != NULL) && my_strmatch(++p, ++lpszString);
while (true)
{
while (*p == '*') ++p;
if (*p == NULL)
return true;
if (*p != '?') break;
++lpszString;
++p;
}
while (true)
{
if ((lpszString = strchr(lpszString, *p)) == NULL)
return false;
if (*lpszString == NULL)
return false;
if (my_strmatch(p + 1, ++lpszString))
return true;
}
return false;
}
Regards,
Serguei Velikevitch,
Dundas Software.
==================
The original message was:
Hi Alex,
thanks for your code. It is ok for the most cases. But there are many cases in which strmatch() will fail:
strmatch("*?s*", "doesmatch"); doesn't work, because after '*' explicit match to '?' is searched.
strmatch("*to*", "doesmatchtoo"); doesn't work because '*t' finds the first 't' and compares "tchtoo" with "to*" - result: no match.
Due to a bug in the '*' case, the function will return false on all wildcards, that end on '*':
else if(*lpszWildCard == '*') { ++ lpszWildCard; while(*lpszWildCard!=*lpszString && *lpszString!=NULL) { ++lpszString; // this is WRONG //if(*lpszWildCard == NULL || *lpszString == NULL) // break; // must be like this: if(*lpszWildCard == NULL) return TRUE; // rest DOES match to '*'! if (*lpszString == NULL) break; } }
I suppose, that a 100% solution requires recursion and is NOT so easy to realize!
-- Thomas ================== The original message was: Hi
I don't know any existing function which can do this but it's very easy to write it yourself.
Here is the fully working example:
bool strmatch(char *lpszWildCard, char *lpszString) { if(lpszWildCard == NULL || lpszString == NULL) { return false; }
while(*lpszWildCard != NULL && *lpszString != NULL) { if(*lpszWildCard == '?') { } else if(*lpszWildCard == '*') { ++ lpszWildCard; while(*lpszWildCard != *lpszString && *lpszString != NULL) { ++lpszString; if(*lpszWildCard == NULL || *lpszString == NULL) break; } } else if(*lpszWildCard != *lpszString) { return false; }
++ lpszString; ++ lpszWildCard; }
if(*lpszString == NULL) { while(*lpszWildCard == '*') { ++lpszWildCard; } }
if(*lpszWildCard == *lpszString) { return true; }
return false; }
Let me know if you have any problems with this code.
Alex Gorev, Dundas Software.
================== The original message was: Hi, does anyone know how to to fnd out whether a string matches a wildcard pattern? Something like int iMatch = wcmatch("??ES*H", "DOESMATCH"); There are lots of functions that use wildcards on filenames or database tables - but I didn' find anything for strings. Any ideas or sample code welcome!
|
|
|
|
|
Regular expressions will give you what you need (and a lot more). I don't know if this site has already received classes to do that but I know there are some in CodeGuru (http://www.codeguru.com/string/index.shtml).
Good luck!
Alvaro
|
|
|
|
|