|
hi.
I have a MDI program done in CFormView which have a scrollbar control. when I minimize the child window and use the scrollbar of the child window, the scrollbar control in the CFormView follows the scrollbar of the child window.
How can I the make the scrollbar control independent of the scrollbar of the child window?
Thank you.
|
|
|
|
|
Hi,
are you setting the parent of the second control bar to the child window?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
hi.
control bar refers to toolbars, status bars, dialog bars and rebars?
Im don't use any of them. I only have menu.
|
|
|
|
|
Hello,
Can someone please tell me how to convert from CString to const* char?
I used the following from msdn website:
<br />
const size_t newsize = 100;<br />
char nstring[newsize];<br />
strcpy_s(nstring, orig);<br />
strcat_s(nstring, " (char *)");<br />
cout << nstring << endl;
But it requires that I compile with clr. When I do that, my classx.cpp (all my class function) are considered errors.
When I don't modify the property of my solution to clr, I still get two errors:
fatal error C1190: managed targeted code requires a '/clr' option
Is there any other way to convert without using clr?
Thank you.
--Star
|
|
|
|
|
This is not clr code, I can't imagine how it gives you this error.
The CString class has a GetBuffer method that returns a char *. Not sure if it is char or TCHAR, but so long as you're not building Unicode, they are the same.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
Why dont you use the "strcpy" and "strcat" respectivily instead of using "strcpy_s" and "strcat_s". Since the later 2 functions have more securuty enchancements you problem could be related with that.
Manoj
Never Give up
|
|
|
|
|
manojkumarrai wrote: Why dont you use the "strcpy" and "strcat" respectivily instead of using "strcpy_s" and "strcat_s".
I guess, one should always use enhanced versions of functions. Isn't it ?
manojkumarrai wrote: have more securuty enchancements you problem could be related with that.
.
How could be that ?
Prasad
MS MVP - VC++
|
|
|
|
|
In addition to previous reply, have a look at CString::operator LPCTSTR .
Again, it depends on project settings.
Prasad
MS MVP - VC++
|
|
|
|
|
HELP! Caption bar buttons don't work on XP display. The minimize/restore/close buttons appear very big on XP and hence when you click on the upper left corner of the minimize button on XP, nothing happens. YOu have to move the mouse the lower right corner of the minimize button to get it to work. Could someone please tell me what i need to do to get the captionbar buttons to work on XP display. Thanx in advance.
////////////////
// Draw min, max/restore, close buttons.
// Returns total width of buttons drawn.
//
int CCaptionPainter:rawButtons(const PAINTCAP& pc)
{
ASSERT(m_pWndHooked);
CWnd& wnd = *m_pWndHooked;
DWORD dwStyle = wnd.GetStyle();
if (!(dwStyle & WS_CAPTION))
return 0;
ASSERT(pc.m_pDC);
CDC& dc = *pc.m_pDC;
int cxIcon = GetSystemMetrics(SM_CXSIZE);
int cyIcon = GetSystemMetrics(SM_CYSIZE);
// Draw caption buttons. These are all drawn inside a rectangle
// of dimensions SM_CXSIZE by SM_CYSIZE
CRect rc(0, 0, cxIcon, cyIcon);
rc += CPoint(pc.m_szCaption.cx-cxIcon, 0); // move right
// Close box has a 2 pixel border on all sides but left, which is zero
rc.DeflateRect(0,2);
rc.right -= 2;
dc.DrawFrameControl(&rc, DFC_CAPTION, DFCS_CAPTIONCLOSE);
// Max/restore button is like close box; just shift rectangle left
// Also does help button, if any.
BOOL bMaxBox = dwStyle & WS_MAXIMIZEBOX;
if (bMaxBox || (wnd.GetExStyle() & WS_EX_CONTEXTHELP)) {
rc -= CPoint(cxIcon, 0);
dc.DrawFrameControl(&rc, DFC_CAPTION,
bMaxBox ? (wnd.IsZoomed() ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX) :
DFCS_CAPTIONHELP);
}
// Minimize button has 2 pixel border on all sides but right.
if (dwStyle & WS_MINIMIZEBOX) {
rc -= CPoint(cxIcon-2,0);
dc.DrawFrameControl(&rc, DFC_CAPTION, DFCS_CAPTIONMIN);
}
return pc.m_szCaption.cx - rc.left - 2;
}
|
|
|
|
|
|
I'd like to use this function instead.... But I'm not sure how I can incorporate it instead of DrawFrameControl if OS ix XP, any ideas?
BOOL
PaintThemeCaptionMaxButtonNormal(
IN CONST HWND hWnd,
IN CONST HDC hDC,
IN CONST POINT ptTopLeft
)
{
BOOL bRet = FALSE;
if (hWnd && hDC)
{
HTHEME hTheme = OpenThemeData(hWnd, L"WINDOW");
if (hTheme)
{
SIZE sz;
if (S_OK == GetThemePartSize(
hTheme, hDC, WP_MAXBUTTON, MAXBS_NORMAL,
NULL, TS_TRUE, &sz))
{
RECT rc;
if (SetRect(&rc, 0, 0, sz.cx, sz.cy) &&
OffsetRect(&rc, ptTopLeft.x, ptTopLeft.y))
{
bRet = (S_OK == DrawThemeBackground(hTheme,
hDC,
WP_MAXBUTTON, MAXBS_NORMAL, &rc, &rc));
}
}
CloseThemeData(hTheme);
}
}
return bRet;
}
|
|
|
|
|
hi,i am new to visual C++ programming. i have a simple visual C++ program that involves basic sql transactions and if a query fails then i have tried to rollback all the previous transactions as well. I am using MS SQL Server. the problem is that the rollback is not working in the tables in the server while when i run the program in the debug mode it shows that the rollback feature is working as it returns a positive integer from the rollback() function. the program shows no errors or warnings.
Can anyone provide some suggestions? For testing i have used three queries in which the third one has been intentionally left wrong. I need the first two queries to be rollbacked when the error occurs in the third query.
Would be glad if you can point out other errors as i am still learning C++ programming...
Attached is the code:
<br />
class test<br />
{<br />
<br />
public:<br />
void testmethod()<br />
{ CDatabase dbobject[100];<br />
static int counter=0;<br />
char query [3][100]={{"Insert into product values (1,'keyboard')"},{"Insert into product values (2,'mouse')"},{"Insert into product values (2,'cable')"}};<br />
try<br />
{<br />
for(int i=0;i<(sizeof(dbobject)/sizeof(dbobject[0]));i++)<br />
{<br />
dbobjectIdea.OpenEx(_T( "DSN=mytest" ),CDatabase::noOdbcDialog );<br />
dbobjectIdea.BeginTrans();<br />
dbobjectIdea.ExecuteSQL(queryIdea);<br />
dbobjectIdea.CommitTrans();<br />
cout<<"Query Execution Successful\n";<br />
counter++;<br />
dbobjectIdea.Close();<br />
}<br />
}<br />
catch (CDBException *pEx)<br />
{<br />
pEx->ReportError();<br />
dbobject[counter].Close();<br />
for(int j=counter-1;j>=0;j--)<br />
{ dbobject[j].OpenEx(_T( "DSN=mytest" ),CDatabase::noOdbcDialog );<br />
dbobject[j].BeginTrans();<br />
int c = dbobject[j].Rollback();<br />
dbobject[j].Close();<br />
cout<<"SQL Query Rollbacked!\n";<br />
}<br />
}<br />
}<br />
};<br />
void main()<br />
{<br />
test t;<br />
t.testmethod();<br />
}
|
|
|
|
|
Sorry for my poor English .
I can't tell you the reason of error . It is different in debug and release , so you can debug in release state .
Project settings -> link -> Generate debug info (selected)
Project settings -> C/C++ -> Debug info(select program database)
Project settings -> C/C++ -> Optimizations(select disable(debug))
Then pass F5 to run program used for debug .
我不能够告诉你错误的原因。debug 版本和 release 版本是不同的,你可以在release状态下调试。你做如下设置
Project settings -> link -> Generate debug info (selected)
Project settings -> C/C++ -> Debug info(select program database)
Project settings -> C/C++ -> Optimizations(select disable(debug))
然后就可以f5进行运行调试了。
|
|
|
|
|
hi, i used the settings you told me. The problem is still there. The rollback does not remove the previous two entries. This time it also shows some 'Detected Memory Leaks!' error. What does that mean?
|
|
|
|
|
hey, thanks for your advice. i solved the problem myself. as you see in my code, i was using an array. i didnt need to use that. i used only a single object and treated the three transactions as a single transaction. it works now.!!
- Moonis
|
|
|
|
|
hi,
does anyone know if a layered window can be a direct3d client window?
Live long and prosper
johny74656@gmail.com
|
|
|
|
|
Using the Win32 API here he is some sample code to get the device context and create a bitmap
HDC hBackDC=NULL;<br />
HDC hdc=GetDC(hWnd);<br />
hBackDC=CreateCompatibleDC(hdc);<br />
<br />
BITMAPINFO bmpInfo;<br />
<br />
ZeroMemory(&bmpInfo,sizeof(bmpInfo));<br />
bmpInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);<br />
bmpInfo.bmiHeader.biBitCount=32;<br />
bmpInfo.bmiHeader.biCompression=BI_RGB;<br />
bmpInfo.bmiHeader.biSizeImage=320*240*4;<br />
bmpInfo.bmiHeader.biPlanes=1;<br />
bmpInfo.bmiHeader.biHeight=240;<br />
bmpInfo.bmiHeader.biWidth=320;<br />
<br />
hBackBitmap=CreateDIBSection(hBackDC,&bmpInfo,DIB_RGB_COLORS,&pBits,NULL,NULL);
where "hWnd" is from LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
I'm wondering how I get the handle of the window (hWnd) in MFC?
Thanks
|
|
|
|
|
bankai123 wrote: I'm wondering how I get the handle of the window (hWnd) in MFC?
See CWnd::GetSafeHwnd()[^]
|
|
|
|
|
bankai123 wrote: HDC hdc=GetDC(hWnd);
There are wrapper classes for such win32 functionalities in MFC .
In this case you can use CDC or derived class.
Prasad
MS MVP - VC++
|
|
|
|
|
Hi,
There's a small problem with my polygons: To create Run codes from my polygon structure I came up with an algorithm that looked up for each horizontal line which polygon lines crossed them and where, then sorting them and going from left to right to check wether the actual point is an entry point, an exit point or a single point that is either ignored (if it's a point that is between two "inside" fractions of the run codes) or results in an one-point run code (if it's a single point between two "outside" fractions. The problem I have is, that I checked for the "entering" the polygon or "leaving" it by checking the pixel to the right of it with a CRgn::PtInRegion. It seemed to work fine, but then (mostly by random) I had a polygon with a horizontal line and had to find out that the pixels on the line seemed to be detected as "outside" by PtInRegion, which resulted in two single-point run codes instead of one run code from the the start point to the end point.
Is there an easy way to check if the point is ON a polygon line, so that I can modify the criterium for the "entering" points by if(PtInRegion(pt) || PtOnLine(pt)), or even better, is there a way to modify the PtInRegion by parameters given to the CRgn object that points on the bounding line are recognized as inside?
Another problem in this context might be the calculation of the crossing points between polygon lines and horizontal lines. If it's not a horizontal line (which means y==y1==y2) I calculate it by a formula x=(x1+(y-y1)*((x2-x1)/(y2-y1))) rounding it to an integer afterwards, but this calculation is too exact, not taking in account the inaccuracy due to alias effects, so some pixels that would be drawn as bounding line for the polygon are not recognized by my algorithm. Is there an easy and fast algorithm that can help me find the min-crossing an max-crossing points to be used in my run code algorithm?
Hope anyone can help
Martin Dietz
|
|
|
|
|
I'm using VC++ 6 under WinXP SP2. After my application exits I get
Detected memory leaks!<br />
Dumping objects -><br />
{61} normal block at 0x02621740, 12 bytes long.<br />
Data: <@ b @ b > 40 17 62 02 40 17 62 02 CD CD CD CD <br />
{60} normal block at 0x02621780, 44 bytes long.<br />
Data: <|h] a] a] b > 7C 68 5D 02 80 61 5D 02 88 61 5D 02 C0 1A 62 02 <br />
Object dump complete.<br />
the same all the time. So, I want to find out, where I'm leaking the memory, so I'm usind _CrtSetBreakAlloc(60) , but it doesn't stop the execution at all. Why it can be so: leak finder reports about leaking in 60th allocation, but fails to stop when it is allocated?! Help me please.
Thank you beforehand.
P.S. Don't worry, I'm building in debug mode.
|
|
|
|
|
And you're using the debug C runtime library?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
How can I make sure that I do?
In "Project settings"|"Link"|"Ignore libraries" I've listed "libc.lib,libcd.lib,msvcrt.lib" some time ago to compile one external project. Does it matter?
|
|
|
|
|
I don't have VC6 but in VS 2003 it's in the
project properties/C++/Code Generation/Runtime Library
It's whatever setting sets the /M compiler option. You'll want
/MTd (multithreaded debug)
or /MDd (multithreaded debug DLL)
or /MLd (singlethreaded debug)
The debug CRT is msvcrtd.lib, not msvcrt.lib.
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Then I do, "Debug Multithreaded", "/MTd" key.
What can be the cause of the problem?
|
|
|
|
|