|
thanx to both of you.
i tried both and it all works fine.
live fast, die young!
|
|
|
|
|
I need to MINIMIZE my app when the app start how can I do that?
|
|
|
|
|
If you are using SDI or MDI app, go to InitInstance method of CWinApp, look for pMainFrame->ShowWindow , change parameter to SW_SHOWMINIMIZED .
ARSALAN MALIK
|
|
|
|
|
One way is to call ShowWindow using SW_MINIMIZE
or add the WS_MINIMIZE style to your CreateWindow call.
Searching for either of these terms on MSDN or Google will provide examples.
Michael
CP Blog [^]
|
|
|
|
|
|
Hello friends,
I want to search all the file present in a particular directory which can be set at run time with a specified extension. For example, I want to search all the file name of extension with .bmp at the path c:\windows. The path C:\windows can be changed to C:\my documents\ at run time depending on the situation. how can i achieve it?
Thank you,
Neelesh Jain.
|
|
|
|
|
Use FindFirstFile and then FindNextFile to enumerate all files. Pass "c:\\documents\\*.bmp" as lpFileName.
ARSALAN MALIK
|
|
|
|
|
To Hello,
With VC 6.0 ActiveX ControlWiizard, the code below was written.
BEGIN_PROPPAGEIDS(CSmileCtrl, 2)
PROPPAGEID(CSmilePropPage::guid)
PROPPAGEID(CLSID_CColorPropPage)
END_PROPPAGEIDS(CSmileCtrl)
On my property page I have only 2 tabs: General and Extended.
Should I have 3 tabs with: General, Color and Extended?
The documentation said that the MFC DLL was not installed properly. Found nothing wrong with the installation.
Please advise.
Thanks.
S1189216G
|
|
|
|
|
Hi,
In my module, the port should be enable which r found in the system.
For example if the sysytem has port1 & port2.
Then they should be enabled in my menu bar.
How is it possible?
PLs help.
mithila
|
|
|
|
|
|
Hello friends,
Here again with another question.
I want to display 4 different images in a single row in a list control. If more number of images are to be displayed then they should be displayed in next row and each image should selected on a click of a mouse button for example "THE THUMBNAILS VIEW" in windows explorer.
Bye bye
thank you
|
|
|
|
|
I want to encrypt the strings in my program (the ones your can read in the exe), so I need to find an easy to use, small, and fast decrypt function. I want something secure too, do you know of any tutorials or source code?
Thanks.
Oh I will encrypt my strings before hand so it does'nt matter if the encryption function is slow or a memory hog
wWw.KruncherInc.cOm
|
|
|
|
|
|
what do you need this for? to prevent crackers from hacking your software? then this way will be very ineffective. they will scan the memory for the decrypted version.
Don't try it, just do it!
|
|
|
|
|
Hi,
I am tryiny to develop a UNICODE version of my application with VC++6.0 under Chinese OS, the CHINESE CHARACTERS that I entered for the COMBOBOX control by its property tab(DATA) could not be displayed correctly under English OS? The other components such as static and button were OK. When I opened the rc file with Notepad, I foud that the other components were written in Chinese, however, the COMBOBOX was written in digital code such as 0x545f.
Does anyone know how to solve this problem?
THANKS!
Robert
REF:
IDD_TESTH_DIALOG DIALOGEX 0, 0, 320, 200
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "TESTH"
FONT 9, "Tahoma"
BEGIN
DEFPUSHBUTTON "确定",IDOK,260,7,50,14
PUSHBUTTON "取消",IDCANCEL,260,23,50,14
LTEXT "TODO: 在这里设置对话控制。",IDC_STATIC,50,106,200,8
COMBOBOX IDC_COMBO1,98,53,177,89,CBS_DROPDOWN | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
EDITTEXT IDC_EDIT1,26,77,40,14,ES_AUTOHSCROLL
COMBOBOX IDC_COMBO2,187,86,48,56,CBS_DROPDOWN | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
END
....
IDD_TESTH_DIALOG DLGINIT
BEGIN
IDC_COMBO1, 0x403, 7, 0
0x545f, 0xca28, 0x29c7, "\000"
IDC_COMBO1, 0x403, 3, 0
0xf1b7, "\000"
IDC_COMBO2, 0x403, 3, 0
0xc7ca, "\000"
IDC_COMBO2, 0x403, 3, 0
0xf1b7, "\000"
IDC_COMBO2, 0x403, 3, 0
0xd0d6, "\000"
0
END
aa
|
|
|
|
|
hi i have this program to do and i am kind of sttucked on the keyboard action
can someone wrote for me the KeyboardFunc with a switch statment and this is the program
a program that allows the user to enter and edit pictures made up of as many as
60 polylines. The user interacts with the screen by pressing the keyboard keys and
pointing and clicking the mouse. The functionality of the program should include the
following “actions”:
Begin (‘b’) – create a new polyline
Delete (‘d’) – delete the next point pointed to
Move (‘m’) – drag the point pointed to to a new location
Insert (‘i’) – insert a new point in the polyline
Refresh (‘r’) – erase the screen and allow user to start from sctrach
Quit (‘q’) – exit from the program
A list of polylines can be maintained in an array such as GlintPointArray polys[60].
The verb begin, activated by pressing the ‘b’ key permits the user to create a new
polyline, which is stored in the first available ‘slot’ in array polys.
The verb delete requires that the program identify which point of the polyline lies
closest to the point currently designated by the mouse. Once that point is identified,
the “previous” and “next” vertices in the chosen polyline are found. The two line
segments connect to the chosen vertex are erased, and the previous and next vertices
are joined with a line segment.
The verb move finds the vertex closest to the currently designated point and waits for
the user to click the mouse a second time, at which point the vertex is moved to the
new point. EQUAL marks will be allocated if you allow the user to click and drag the
point interactively!
Your program should also allow the user to read in a file containing a list of polylines
into an array and allow the user to manipulate these points.
and this is the mouse function
#include <windows.h>
#include <gl gl.h="">
#include <gl glu.h="">
#include <glut.h>
const int screenHeight=480;
class GLintPoint{
public:
GLint x,y;
};
void myInit(void)
{
glClearColor(0.0,1.0,1.0,0.0);
glColor3f(1.0,0.0f,1.0f);
glPointSize(9.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,440.0,0.0,480.0);
}
void myMovedMouse(int mouseX, int mouseY)
{
GLint x = mouseX; //grab the mouse position
GLint y = screenHeight - mouseY; // flip it as usual
GLint brushSize = 5;
glRecti(x,y, x + brushSize, y + brushSize);
glFlush();
}
void myMouse(int abutton, int state, int x, int y)
{
static GLintPoint points[3];
static int numPoints = 0; // initial value is 0
if(abutton == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
{
points[numPoints].x = x;
points[numPoints].y = screenHeight - y; // flip y coordinate
numPoints++; // have another point
if(numPoints == 3)
{
glBegin(GL_POLYGON);
glVertex2i(points[0].x, points[0].y);
glVertex2i(points[1].x, points[1].y);
glVertex2i(points[2].x, points[2].y);
glEnd();
//Recti(corner[0].x, corner[0].y, corner[1].x, corner[1].y);
numPoints = 0; // back to 0 corners
}
}
else if(abutton == GLUT_RIGHT_BUTTON && state == GLUT_DOWN)
glClear(GL_COLOR_BUFFER_BIT); // clear the window
glFlush();
}
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}
void main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(480, 480);
glutInitWindowPosition(100, 150);
glutCreateWindow("my first attempt");
glutDisplayFunc(myDisplay);
glutMouseFunc(myMouse);
glutMotionFunc(myMovedMouse);
myInit();
glutMainLoop();
}
|
|
|
|
|
Hello all, I am getting a segmentation fault when trying to access an array... I know this is silly, am I overlooking something? What the hell? The problem seems to occur when accessing an array from the bigFish function. Please teach me..
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
struct fish{
int contestant[99999];
int fishNumber[99999];
float fishWeight[99999];};
void readFiles(int contest[20], string name[20], int fishNum[5],
string fishType[5], fish fishStruct);
void bigFish(int contest[20], string name[20], int fishNum[5],
string fishType[5], fish fishStruct);
int main()
{
fish fishStruct;
int choice = 0; //choice in menu
cout.setf(ios::fixed, ios::floatfield);
cout.setf(ios::showpoint);
cout.precision(2);
int contest[20];
string name[20];
int fishNum[5];
string fishType[5];
readFiles(contest, name, fishNum, fishType, fishStruct);
cout<<"MENU: PLEASE MAKE A SELECTION"<<endl<<endl;
cout<<"1.="" display="" all="" data="" for="" a="" contestant"<<endl;
="" cout<<"2.="" total="" catch="" weight="" fish="" type"<<endl;
="" cout<<"3.="" largest="" caught"<<endl<<endl;
="" cout<<"choose="" and="" option="" between="" 1-3"<<endl;
="" cin="">>choice;
if (choice == 3)
bigFish(contest, name, fishNum, fishType, fishStruct);
return 0;
}
void readFiles(int contest[20], string name[20], int fishNum[5], string fishType[5], fish fishStruct)
{
ifstream inFile;
inFile.open("contestantname.data");
if (!inFile)
{
cout<<"contestantname.data not found"<<endl;
}
="" clearing="" out="" the="" array
="" for(int="" i="0;" <="" 20;="" i++)
="" {
="" contest[i]="0;
" name[i]=" " ;
="" int="" count1="0;
" while(infile)
="" infile="">>contest[count1];
inFile>>name[count1];
cout<<name[count1]<<endl;
count1++;
="" }
="" infile.close();
=""
="" infile.open("fishtype.data");
="" if="" (!infile)
="" {
="" cout<<"fishtype.data="" not="" found"<<endl;
="" clearing="" out="" the="" array
="" for(int="" i="0;" <="" 20;="" i++)
="" fishnum[i]="0;
" int="" count2="0;
" while(infile)
="" infile="">>fishNum[count2];
inFile>>fishType[count2];
count2++;
}
inFile.close();
inFile.open("catch.data");
if (!inFile)
{
cout<<"catch.data not found"<<endl;
}
="" clearing="" out="" the="" array
="" for(int="" i="0;" <="" 20;="" i++)
="" {
="" fishstruct.contestant[i]="0;
" fishstruct.fishnumber[i]="0;
" fishstruct.fishweight[i]="0;
" int="" count3="0;
" while(infile)
="" infile="">>fishStruct.contestant[count3];
inFile>>fishStruct.fishNumber[count3];
inFile>>fishStruct.fishWeight[count3];
count3++;
}
inFile.close();
}
void bigFish(int contest[20], string name[20], int fishNum[5],
string fishType[5], fish fishStruct)
{
int num = 0; //temp contestant number
int totalWeight = 0; //weight for each contestant
string tempName; //temp contestant name
cout<<"Please enter contestant number"<<endl;
cin="">>num;
for(int i = 0; i < 20; i++)
{
cout<
|
|
|
|
|
In the bigFish function, instead of passing the entire arrays as parameters, pass the address of the first cell (&name[0], for example, and function parameter is string*). All other code in this function can remain unchanged.
As the 'name' parameter is of type 'string', have you made sure that the 'string' class supports the << operator ? If it doesn't, the std::cout will cause serious problems.
Also, the program wastes huge amounts of stack memory with those 99999 slot arrays. Most obviously the process runs out of memory, thus causing a segmentation fault. This is because you have large arrays of integers that are static. They consume the stack memory of the process, which is limited, and will quickly run out.
If you do not know what dynamic memory allocation is about, you should go grab a good C++ book from the local library and read it through with thought. Dynamic memory allocation is one of the key concepts of efficient programming.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
OK it's official - I'm a moron.
Here I was tearing my hair out trying to figure out how to switch my mainframe's menu at startup (btw, thanks for the code snippet, Neville!) when the answer was right in front of my nose.
CMyApp::InitInstance()
{
...
bool bSpecialMode = ...;
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame
(bSpecialMode ? IDR_MAINFRAME_SPECIAL : IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
...
} I'm going to give up writing code and move to the hills.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
it's official - I'm a moron
If you were one, you wouldn't give the solution in this forum to help anybody else encoutering the same problem
Fold With Us!
Nun liebe Kinder gebt fein acht
Ich bin die Stimme aus dem Kissen...
|
|
|
|
|
Hi Everybody,
Do any one know how to convert a file from EMF to SWF.
Thanks & Advance,
Azghar
If you have faith in cause and
the means and in God, the hot
Sun will be cool for you.
|
|
|
|
|
There is a SWF SDK, you will need to download it and learn how it works.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hello,
I have a tricky situation happening in an app which loads a DLL and then tries to retrieve some procedure's addresses. Consider the following code:
void CDesktopPositionerDlg::OnCapture()
{
DFUNC_DEF(CDesktopPositionerDlg::OnCapture);
BOOL (__stdcall *lpSetup)();
BOOL bRetVal;
bRetVal = theApp.m_hModule != NULL;
if(!bRetVal)
goto loc_ret;
lpSetup = ::GetProcAddress(theApp.m_hModule, "Setup");
bRetVal = lpSetup != NULL;
if(!bRetVal)
{
DTRACE(DSTR("Could not retrieve dll function address (err.#%d)", ::GetLastError()));
goto loc_ret;
}
(*lpSetup)();
.
:
.
loc_ret:
DFUNC_RET2(bRetVal != FALSE, "Mouse hook not setup!", "Mouse hook successfully setup");
}
Now notice the call to ::GetProcAddress . If you change the name of the setup function to _Setup@0 , which is the name defined in the .LIB file, all is fine and the hook is successfully setup.
What I would like to know is the linker option (or C calling convention) I have to adopt in order to prevent such situations from happening.
As always, all comments are welcome.
David
|
|
|
|
|
I must ask, however inconvinient it sounds, what is the situation you wish to prevent ?
Are you, per chance, failing to retrieve the address of the function, unless you name the parameter of GetProcAddress to "_Setup@0" ?
How did you export the function from the DLL ? Or was it built by someone else ? Was it built with Visual Studio ? These questions are imperative, mostly because if the last answer is positive, there are two ways of exporting functions from a DLL.
If you have access to the DLL code, you should add a __declspec(dllexport) calling convention in front of the setup function. Also, create a module definition file (.DEF) inside the DLL project. Paste the following text into it
LIBRARY "MyDLL.DLL"
EXPORTS
Setup @0 When you now build the DLL, the GetProcAddress will not fail if you use "Setup" as the function name. Before, you built the DLL using the default settings. In such a case, the exported routines are added with the underscore in front of them. It is called 'behaviour by default' in Microsoft's terms. The only way to remedy it is to use a module definition file. The __declspec definition is added for increased compatibility, as in, fail-safe exporting.
Also, if you're using dynamic loading (LoadLibrary), the library file is useless. Library files generated for DLL's are only usable if static linking is used, or if the DLL contains a registered COM component (DirectX applications, for an example).
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi Antti and thanks for the reply.
Antti Keskinen wrote:
Are you, per chance, failing to retrieve the address of the function, unless you name the parameter of GetProcAddress to "_Setup@0" ?
That's it basically. After having finished the DLL I tried to access some of its functions in my MFC App by calling GetProcAddress and passing the names of the functions. It didn't work.
Well it happens that, after taking a look at the .MAP file, all the functions are added the underscores and also some additional characters. Therefore, trying to retrieve Setup 's proc address from the Dll would only work if I called GetProcAddress passing _Setup@0 .
I don't really know the workarounds one has/can do in order to prevent this from happening. I mean, how can I export the function as is, making it accessible by its true name?
Will I have to create a definition file for the Dll?
Again, thanks for the reply.
By the way, I am using the __declspec(dllexport) calling convention.
|
|
|
|
|