|
Also, make sure that you have the whole dialog selected and not one of the controls. I have had many brain farts and not done this...
Larry J. Siddens
|
|
|
|
|
ldsdbomber wrote: but I dont know what DLU are
It stands for DiaLog Units. A DLU is based on the size of the dialog box font, normally 8-point MS Sans Serif. A horizontal DLU is the average width of the dialog box font divided by four. A vertical DLU is the average height of the font divided by eight.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi.I'm doing a Visual c++2005 project.
I've implemented a class A in a cpp file like this:
class A
{...constructor,methods,and so on
};
Then i've to use an object of this class in another file(my form.h file of the graphic interface)
and i want that the object is visible to all methods of this class so that i can use its properties.
I've put my #include a.h but where must i have to declare it to use it as "a global variable"?
I can use it only if i declare it in a method but it's not visible from the other methods.
If i declare it in the constructor of the class the methods don't see the object.
Thanks for answers, regards.
|
|
|
|
|
If I under stand your question correctly, you have something like this...
<pre>
class MyClass
{
public:
MyClass() { ... }
~MyClass() { ... }
void myFunction( ... );
int getInt();
void setInt( int x );
private:
int myInt;
}
</pre>
And you have your .cpp file. Then you do something like this (different source file):
<pre>
#include "myClass.h"
MyClass myObject;
... Other stuff...
</pre>
Then to have it global.
<pre>
#include "MyClass.h"
extern MyClass myObject;
</pre>
Is this what your trying to do?
Larry J. Siddens
|
|
|
|
|
I try to explain my problem...
class MyClass
{
public:
MyClass() { ... }
~MyClass() { ... }
void myFunction( ... );
int getInt();
void setInt( int x );
private:
int myInt;
}
in a .cpp file.
Then I've have my form.h where i want to use an object of Myclass
#pragma once
namespace WinCam {
using namespace System;
public ref class Form1 : public System::Windows::Forms::Form
{
private: System::Windows::Forms::TabPage^ tabPage1;
...
public:
Form1(void)
{
InitializeComponent();
//////......
}
protected:
~Form1()
{...
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
//here i want to use an object of the a class.
ob.Myfunction();
}
private: System::String^ loadtext(void){
//here i want to use the same object.
int n;
n=ob.getint();
}
....
Where and how must i have to declare Myclass ob=new Myclass()??
thanks, regards.
|
|
|
|
|
Do you want a global variable or a member variable accessible to the class it belongs to?
A global variable you define outside of any class...
A a;
A member variable is defined in a class...
class MyClass
{
protected: //public, private - whatever is appropriate
A a;
...
}
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I try to explain my problem...
class MyClass
{
public:
MyClass() { ... }
~MyClass() { ... }
void myFunction( ... );
int getInt();
void setInt( int x );
private:
int myInt;
}
in a .cpp file.
Then I've have my form.h where i want to use an object of Myclass
#pragma once
namespace WinCam {
using namespace System;
public ref class Form1 : public System::Windows::Forms::Form
{
private: System::Windows::Forms::TabPage^ tabPage1;
...
public:
Form1(void)
{
InitializeComponent();
//////......
}
protected:
~Form1()
{...
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
//here i want to use an object of the a class.
ob.Myfunction();
}
private: System::String^ loadtext(void){
//here i want to use the same object.
int n;
n=ob.getint();
}
....
Where and how must i have to declare Myclass ob=new Myclass()??
thanks, regards.
|
|
|
|
|
dodoxor wrote: Where and how must i have to declare Myclass ob=new Myclass()??
Here's one possible way - adding a MyClass pointer member object, allocated in the constructor,
freed in the destructor...
public ref class Form1 : public System::Windows::Forms::Form
{
private:
System::Windows::Forms::TabPage^ tabPage1;
...
protected:
MyClass *pMyClassObject;
public:
Form1(void)
{
InitializeComponent();
pMyClassObject = new MyClass();
}
protected:
~Form1()
{
delete pMyClassObject;
}
private:
System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
pMyClassObject->Myfunction();
}
System::String^ loadtext(void)
{
int n;
n=pMyClassObject->getint();
}
}
Here's another possible way - adding a MyClass member object...
public ref class Form1 : public System::Windows::Forms::Form
{
private:
System::Windows::Forms::TabPage^ tabPage1;
...
protected:
MyClass MyClassObject;
public:
Form1(void)
{
InitializeComponent();
}
protected:
~Form1()
{
}
private:
System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
MyClassObject.Myfunction();
}
System::String^ loadtext(void)
{
int n;
n=MyClassObject.getint();
}
}
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I'm still in the process of switching a program over from VC6 to VS2005. I have encounter a problem, the program uses and array with imaginary numbers, and uses a function called ".SetTo". it is defined in complexclass.h/complexclass.cc, but I cannot find a C++ version of this library but from my understanding is is a standard library.
d[1].SetTo(0.200000,0)
where d[] is a complex arrary
Any help would be great.
-- modified at 11:18 Friday 18th May, 2007
|
|
|
|
|
simoncoul wrote: but from my understanding is is a standard library.
Never heard of it. What is the source of your understanding?
led mike
|
|
|
|
|
alrite I've been able to get the program to run off of the standard complex.h library, all I'm trying to do is put the real and imaginary part of a number into a complex array at the same time. Using the SetTo function it allowed me to do that.
So I'd have a value (a,jb) where "a" is real and "b" is imaginary, and I want to put into an array d[] which is complex, any ideas of how to do this?
|
|
|
|
|
What were you using in the VC6 version of your app?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
A magic Fish Filet of course. You ask silly questions.
led mike
|
|
|
|
|
Check out my profile picture...
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
thanks for the help I was able to figure it out.
d[1].SetTo(a,jb) becomes d[1] = complex(a,jb) ,
|
|
|
|
|
|
Hi. This code gives error
#pragma once<br />
#include <afxwin.h><br />
<br />
class CApp : public CWinApp<br />
{<br />
public:<br />
virtual BOOL InitInstance();<br />
};<br />
<br />
class CWindow : public CFrameWnd<br />
{<br />
public:<br />
CWindow();<br />
};<br />
<br />
CApp theApp;<br />
#include "main.h"<br />
<br />
BOOL CApp::InitInstance()<br />
{<br />
this->m_pMainWnd = new CWindow;<br />
this->m_pMainWnd->Create( NULL, L"Window", WS_OVERLAPPEDWINDOW);<br />
this->m_pMainWnd->ShowWindow(m_nCmdShow);<br />
this->m_pMainWnd->UpdateWindow();<br />
return TRUE;<br />
};
Now it gives error: error C2660: 'CWnd::Create' : function does not take 3 arguments 6
If I change it
BOOL CApp::InitInstance()<br />
{<br />
this->m_pMainWnd = new CWindow;<br />
this->m_pMainWnd->ShowWindow(m_nCmdShow);<br />
this->m_pMainWnd->UpdateWindow();<br />
return TRUE;<br />
};<br />
CWindow::CWindow()<br />
{<br />
Create( NULL, L"Window", WS_OVERLAPPEDWINDOW);<br />
}
Works well.
Why does 3 parameters give error in InitInstance but not in constructor?
Thanks
|
|
|
|
|
The only thing I can think of is in InitInstance(), the compiler doesn't know m_pMainWnd is
a CFrameWnd-derived class object. CWnd's Create() needs 6 params, CFrameWnd's Create() only
needs 2.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
One is CFrameWnd::Create(2 req'd arguments) while the other is CWnd::Create(6 req'd arguments) .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
can any buddy tell me that how can i Retrieve a "Tree Element" path in String format using CTreeCtrl class member's.
thanks
Pankaj Jain
|
|
|
|
|
There is no "standard" way that I know of to do that. You would simply have to take the selected/current item, and in a loop:
Get the text for the item
Get the current item's parent
Repeat until top of tree is reached.
You can then format the item's text however you need to.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Dear Sirs,
I am using sql server 2000 database,
so i want to use Sql server security to protect my data.
To use this, we are wondered to use Views, to apply security .
Hence I want to know if from Visual c++ language, is it possible to use SQl Server Views ? Give me same examples if possible
I learn my self
|
|
|
|
|
I got pbuffer from a camera device. Now i have to make bitmap and show in thumnail view.
LPBYTE pBuffer=new BYTE[height*width*3];
memcpy(pBuffer,(LPBYTE)lParam,height*width*3);
what i did:
DrawThumbnails(){
CBitmap* pImage = NULL;
HBITMAP hBitmap = NULL;
HDC hMemDC = NULL;
HGDIOBJ hOldObj = NULL;
POINT pt;
int x, i; // = m_ImageListThumb.GetImageCount();
CString str;
str.Format("%d",pBuffer);
AfxMessageBox(str);
// no images
// set the length of the space between thumbnails
// you can also calculate and set it based on the length of your list control
int nGap = 6;
// hold the window update to avoid flicking
m_ListThumbnail.SetRedraw(FALSE);
// reset our image list
// for( i=0; i<m_imagelistthumb.getimagecount(); i++)
="" m_imagelistthumb.remove(i);=""
="" remove="" all="" items="" from="" list="" view
="" if(m_listthumbnail.getitemcount()="" !="0)
//" m_listthumbnail.deleteallitems();
="" set="" the="" size="" of="" image="" list
="" m_imagelistthumb.setimagecount(m_vectorimagenames.size());
="" m_imagelistthumb.setimagecount(0);
="" i="0;
"
="" bitmapinfoheader="" bih;
="" memset(="" &bih,="" 0,="" sizeof(="" bih="" )="" );
="" bih.bisize="sizeof(" bih.biwidth="m_nWidth;
" bih.biheight="m_nHeight;
" bih.biplanes="1;
" bih.bibitcount="24;
" bih.bicompression="0;
" bih.bisizeimage="0;
" bih.bixpelspermeter="3780;
" bih.biypelspermeter="3780;
" bih.biclrimportant="0;
" bih.biclrused="0;
" bitmap="" bitmap;
="" memset(&bitmap,0,sizeof(bitmap));
="" bitmap.bmbits="pBuffer;
//" bitmap.bmbitspixel="24;
//" bitmap.bmheight="m_nHeight;
//" bitmap.bmplanes="1;
//" bitmap.bmtype="0X4D42;
//" bitmap.bmwidth="m_nWidth;
//" bitmap.bmwidthbytes="12;
" bitmapinfo="" bmi;
="" bmi.bmiheader="bih;
" put="" bits="" into="" preview="" window="" with="" stretchdibits
="" hwnd="" hwndstill="this-">m_hWnd;
// create thumbnail bitmap section
bih.biWidth = THUMBNAIL_WIDTH;
bih.biHeight = THUMBNAIL_HEIGHT;
// hBitmap = CreateBitmapIndirect(&bitmap);
hBitmap = ::CreateDIBSection(NULL,&bmi, DIB_RGB_COLORS, NULL, NULL, 0);
//hBitmap = ::CreateDIBitmap(hDC,&bih,CBM_INIT,pBuffer,(BITMAPINFO*)&bih,DIB_RGB_COLORS);
//hBitmap = CreateBitmap(m_nWidth,m_nHeight,1,24,)
// restore dib header
//dib.m_pBMI->bmiHeader.biWidth = nWidth;
//dib.m_pBMI->bmiHeader.biHeight = nHeight;
bih.biWidth= m_nWidth;
bih.biHeight = m_nHeight;
// select thumbnail bitmap into screen dc
hMemDC = ::CreateCompatibleDC(NULL);
hOldObj = ::SelectObject(hMemDC, hBitmap);
// HDC hDC = pdc->GetSafeHdc();
::SetStretchBltMode(hMemDC, COLORONCOLOR);
// grayscale image, need palette
// if(dib.m_pPalette != NULL)
// {
// hPal = ::SelectPalette(hMemDC, (HPALETTE)dib.m_pPalette->GetSafeHandle(), FALSE);
// ::RealizePalette(hMemDC);
// }
// set stretch mode
//::SetStretchBltMode(hMemDC, COLORONCOLOR);
// populate the thumbnail bitmap bits
// ::StretchDIBits(hMemDC, 0, 0,
// THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT,
// 0, 0,
// dib.m_pBMI->bmiHeader.biWidth,
// dib.m_pBMI->bmiHeader.biHeight,
// dib.m_pBits,
// dib.m_pBMI,
// DIB_RGB_COLORS,
// SRCCOPY);
::StretchDIBits(
hMemDC, 0, 0,
THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, //lStillWidth, lStillHeight,
0, 0, m_nWidth, m_nHeight,
pBuffer,
&bmi,
DIB_RGB_COLORS,
SRCCOPY);
//EndPaint(&ps);
// restore DC object
// ::SelectObject(hMemDC, hOldObj);
// restore DC palette
// if(dib.m_pPalette != NULL)
// ::SelectPalette(hMemDC, (HPALETTE)hPal, FALSE);
// clean up
::DeleteObject(hMemDC);
// ReleaseDC(pdc);
// attach the thumbnail bitmap handle to an CBitmap object
pImage = new CBitmap();
pImage->Attach(hBitmap);
// add bitmap to our image list
m_ImageListThumb.Replace(i, pImage, NULL);
//x= m_ImageListThumb.GetImageCount();
// put item to display
// set the image file name as item text
m_ListThumbnail.InsertItem(i, NULL, i);
// get current item position
m_ListThumbnail.GetItemPosition(i, &pt);
//
// shift the thumbnail to desired position
pt.x = nGap + i*(THUMBNAIL_WIDTH + nGap);
m_ListThumbnail.SetItemPosition(i, pt);
i++;
str.Format("%d",i);
AfxMessageBox(str);
// let's show the new thumbnails
m_ListThumbnail.SetRedraw(TRUE);
}
the probable problem is in CreateDibSection
Can any one help me?
Mazhar
|
|
|
|
|
you don't say what the error is, or what results you're getting. but, i see one big problem:
CreateDIBitmap and CreateDIBSection require that the pixels are arranged the way they are arranged in a DIB:
1. rows are ordered bottom-up
2. rows are padded to multiples of 4 bytes each
3. RGB pixels are in BGR color order
your buffer of w * h * 3 pixels is almost certainly not accounting for requirement 2.
|
|
|
|
|
i want to send a dos cmd to system as we do in dos OS, how to do ?
|
|
|
|
|