|
Hi
I created a MFC application and created a horizontal scroll bar using CScrollBar calss as follows instead of default scroll bar.
if (CScrollView::OnCreate(lpCreateStruct) == -1)
return -1;
m_horzscrollbar.Create(WS_CHILD | WS_VISIBLE | SBS_HORZ | SBS_BOTTOMALIGN, CRect(0,0,100,100), this, 101);
SCROLLINFO scrollInfo = { 0 };
scrollInfo.fMask = SIF_ALL;
scrollInfo.cbSize = sizeof(SCROLLINFO);
scrollInfo.nMin = 0;
scrollInfo.nMax = 1000;
scrollInfo.nPage = 10;
scrollInfo.nPos = 10;
scrollInfo.nTrackPos = 10;
m_horzscrollbar.SetScrollInfo(&scrollInfo);
m_horzscrollbar.ShowWindow(1);
The above piece of code created a horizontal scroll bar. When i right click on the scroll bar, it displaying a context menu with some options like page left, page right, scroll here, scroll left and scroll left.
How can i stop this default context menu in my application since this is not required for me.
Any help is appreciated.
Thanks.
|
|
|
|
|
|
I have tried this but its not working. One more wired problem i face is, this context menu is not appearing in debug mode, only in release mode this menu is appeared.
|
|
|
|
|
Not tested but should work:
Derive your own CScrollBar based class and implemement OnContextMenu() as empty function. Then the default implementation should not be called anymore.
|
|
|
|
|
Thanks. The trick worked.
|
|
|
|
|
Hello All,
I am working on a legacy application , i am seeing it has some .Def file that is using to generate some cpp file and its used inside the same project.
Can somebody help me in understanding how to invoke .Def file.
vikas da
|
|
|
|
|
|
Thank you so much
Richard MacCutchan
for reply. so project looks like this,
project structure looks like this.
it has a def file that has function to be exported,
it has a generator.cpp that generates x.cpp file
it has x.cpp file that expose some function that is used in other projects
now first i have to use .def file to invoke methods in Generator.cpp to generate the x.cpp file and then compile the project so that the generated dll can be used by other application.
what i am not aware of ...how to invoke Generator.cpp ...is there any parameter that i can tweak during compilation time so that it generate the CPP files first and then compile the DLL or any other possible way
Thank you so much in advance
vikas da
|
|
|
|
|
I am sorry but it is impossible to guess what the build process is supposed to be. You need to find the person who set the project up in the first place.
|
|
|
|
|
Thank you Richard , the person has quit... i guess i would need some more time to understand this code.
vikas da
|
|
|
|
|
Sorry I cannot offer any better suggestions. But without seeing the entire project (which I do not want to do) it is difficult to make any useful guesses.
|
|
|
|
|
i am thinking to give some details ,
my CPP file looks like this
... headers
#ifdef _USRDLL
#pragma comment(linker, "/EXPORT:GenerateFiles=?GenerateFile@@YGJPAUHWND__@@PAUHINSTANCE__@@PADH@Z")
#endif
__declspec(dllexport) HRESULT __stdcall GenerateFiles(HWND hwnd,HINSTANCE hinst,LPSTR lpCmdLine,int nCmdShow)
{
/// some code to generate CPP files exposing by the DLL
}
now can i invoke GenerateFiles method during build process some way ?
vikas da
|
|
|
|
|
Sorry, I have no idea. Where is that function called from, and what is it supposed to do?
|
|
|
|
|
here ih the code below i have tried to add two matrix objects and assign it to the third object but it doesn't give expected result and the rather some garbage value.
include <iostream>
using namespace std;
class matrix{
int **p;
int d1, d2;
public:
matrix(int x=20, int y=20);
void get_element();
void put_element();
int checkAdd(matrix &);
matrix operator + (matrix &);
void operator = (matrix );
~matrix(){
for (int i = 0; i < d1; i++)
delete p[i];
delete p;
}
};
matrix temp;
void matrix::operator = (matrix obj){
this->d1 = obj.d1;
this->d2 = obj.d2;
for(int i=0; i<d1; i++)
for(int j=0; j<d2; j++)
this->p[i][j] = obj.p[i][j];
}
matrix matrix::operator+(matrix &obj){
if(checkAdd(obj)==0)
{
for(int i=0; i<obj.d1; i++)
for(int j=0; j<obj.d2; j++)
temp.p[i][j] = this->p[i][j] + obj.p[i][j];
return(temp) ;
}
cout<<"coloumn and rows of both matrix are not equal !"<<endl;
return (*this);
}
matrix ::matrix(int x, int y)
{
d1 = x;
d2 = y;
p = new int *[d1];
for(int i=0; i<d1; i++)
p[i] = new int [d2];
}
int matrix::checkAdd(matrix &obj){
if((this->d1 == obj.d1) && (this->d2 == obj.d2))
return 0;
else return 1;
}
void matrix::get_element(){
for(int i=0; i<d1; i++)
for(int j=0; j<d2; j++){
cout<<"m["<<i<<"]["<<j<<"] = ";
cin>>p[i][j];
}
}
void matrix::put_element(){
cout<<"\n\n";
for(int i=0; i<d1; i++){
for(int j=0; j<d2; j++){
cout<<p[i][j]<<"\t";
}
cout<<endl;
}
}
int main(){
matrix A(3, 2), B(3, 2), C;
cout<<"Enter matrix elements row by row \n\n";
A.get_element();
A.put_element();
B.get_element();
B.put_element();
C = A + B;
cout<<"\n\n";
C.put_element();
return 0;
}
thank you
|
|
|
|
|
I think it may have something to do with your static temp object. Try creating temp inside your operator+ overload.
|
|
|
|
|
but if i create it inside the operator+ function, i wont be able to assign the value of object temp to object C in main(). As temp scope will only be operator+ function and as soon as the operator+ function is called off, the address that i am passing to the C will no longer point to the values of temp object.
|
|
|
|
|
I have not done operator overloading for a while but that is my recollection of how it should be done. You should be able to find some samples through Google.
|
|
|
|
|
|
Hi.
I created a class which is derived from CTabView. In OnCretae() function it created a window with a tab control on window. Later i created few views by calling AddView(). I created 5 view.
Now, when i click on the arrow buttons on the tab control below, my control is not switching the tabs.
May i know which function should i call to switch the tabs on my window?
|
|
|
|
|
|
Hi.
In my MFC application, i created a class which is derived from CTabView and created few tabs(views) using AddView(). Now i want to change the color of the tab views. May i know how to change the background color of those views?
Thanks in Advance.
|
|
|
|
|
|
i am trying to take multiple names by using getchar() but it only taking the first value and just skipping the rest.
here is the code.
#include <stdio.h>
int main()
{
char name[10][30], ch;
int i;
for(i=0; i<10; i++)
{
printf("Enter name: \n");
int j=0;
while(ch != '\n')
{
ch = getchar();
name[i][j] = ch;
j++;
}
name[i][j] = '\0';
}
return 0;
}
|
|
|
|
|
Because at the end of the first time round the while loop ch will contain the newline character, so every other loop will terminate immediately. You must remember to reset variables after you have finished with them. Please get yourself a good study guide on C and learn the language the proper way.
|
|
|
|
|
In addition to what Richard wrote, you have limited the names to 30 characters so make sure more than that are not entered.
|
|
|
|