|
mikobi wrote: Where to write it and whow ? syntax
It seems to your question on the previous message you said Im new to Visual c++.Net but in the continue you said I was using Visual C++ and MFC.if you used of c++.net so you must ask on the (Managed) C++/CLI[^] forum but if you use of Visual C++ you are on the correct forum.
|
|
|
|
|
I have a linked list that stores strings and there locations, I should save this list to a file and then load it from the same file, I wrote the following functions :
////Save list to a File
void list::store()
{
ofstream write;
write.open("d:\\info.txt");
if(write==NULL)
{
cout<<"Error opening File"<<endl;
return;
="" }
="" node*="" ptr="head;
" while(ptr)
="" {
="" write<<ptr-="">data<<" ";
write<<ptr->location<<" ";
ptr=ptr->next;
}
write.close();
}
////Load list to a File
void list::load()
{
string tempname,templocation;
ifstream read;
read.open("d:\\info.txt");
if(read==NULL)
{
cout<<"Error opening File"<<endl;
return;
="" }
="" while(!read.eof())
="" {
="" read="">>tempname>>templocation;
insert(tempname,templocation);
}
read.close();
}
the store function works properly, my problem is in the load function, when I run it, it fails to detect the end of file "info", so the while loop becomes infinite. how can I make it detect the end of the file ?
|
|
|
|
|
That while() loop should terminate and not be infinite.
I see one problem in your load() method - the last pair of strings will be inserted twice because
you always write a space after the strings. You shouldn't write a space after the last string
written.
Mark
"I'm the Dude. So that's what you call me. You know, that or, uh, His Dudeness, or uh, Duder, or El Duderino if you're not into the whole brevity thing." The Big Lebowski
|
|
|
|
|
Hi all,
I have made a sdi application and it has a splitter control in it which divide my mainframe window in two horizontal parts. Each window class is derived from ClistView.Now i want a progress bar in one class. i have found various article which have shown how to integrate a progress bar in list control.but they all say to include a class and nake a variable of that class and then use it to create element but i don't want a already created class as i have to use
CListCtrl& list = GetListCtrl();
Can anybody tell me to how to create it..
thanks in advance
|
|
|
|
|
You might have seen the utility named Windows Blinds that skins the entire windows enviroment. I am wondering how they do that? any idea? do the subclass every global control class? or what?
Polite Programmer
More Object Oriented then C#
|
|
|
|
|
how to create a destructor for a dlg.cpp class? i created a destructor for my dialog say mydialoDlg.cpp. but it shows error? how to create this? pls help me
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
What error?
You should be able to add the declaration for the destructor to the class:
class CmydialoDlg : public CDialog
{
public:
virtual ~CmydialoDlg();
};
and implement the destructor:
CmydialoDlg::~CmydialoDlg()
{
// destruct stuff here
}
"I'm the Dude. So that's what you call me. You know, that or, uh, His Dudeness, or uh, Duder, or El Duderino if you're not into the whole brevity thing." The Big Lebowski
|
|
|
|
|
Hi
I am making an application in vc++ using modal dialog based.
I want to print a bill report from it.(Note all entries of bill like
product serial no , quentity and price come from database (MySQL))
I can get entries from data base Now i want to print its report. How can i do this.
Can any one give me any example for it or give me some hint for making it
Regard's
Kaushik
|
|
|
|
|
Simplay open port using createfile. File name is like "COM1".....3, "LPT1"....3 and write data after formating it, and flush buffer. After printing close File.
Manish
|
|
|
|
|
sir ji
i am new in vc++ and this is my first application .
can you give me any example related to this or any atricle link.
Regard's
Kaushik
|
|
|
|
|
The shortcut for the exe created by installer is not having the exe name but if create the shortcut manually it contains the exe name also. But both are working correctly. Why there is difference? Also if we see property for installer created shortcut, it is having only 2 tabs while manual shortcut have 3 tabs.
Best Regards,
Suman
|
|
|
|
|
I tried profiling the initial stage of my game engine today, and found out that in win32, the timing is not done correctly. The timing per frame is around 0.016-0.017 seconds (all of the time in x64, but only most of the time in win32). In win32, I will get occasional times that are in the order of 10^-5 seconds and also timing that is around 0.033-0.034 seconds (double the usual). It almost seems like the extra long timings are there to compensate for the extra short timings. Now, I've had this issue before, and I know that QueryPerformanceCounter can have issues on multiple cores / processors, as timing may jump from one processor to the other (and you may even end up with negative values when you subtract current minus last tick), which is why I call SetThreadAffinityMask() right before I do the timing and call SetThreadAffinityMask() again after that, to revert to the previous mask. Unfortunately, even with SetThreadAffinityMask(), your thread is not guaranteed to run on the core that you specify -- it is only a hint to the Windows operating system that you'd like to run on a specific core, so I can understand why I would still have issues even then, but what I don't understand is why compiling with the x64 compiler (running Visual C++ 2005 Pro) makes things work perfectly. Is there a fundamental hardware counter difference with win32 vs. x64 (or maybe a way that the timing is done)?
MODIFIED: I should mention, I get 0.016 because of Vsync, which does not allow you to go past 60 fps.
-- modified at 22:39 Friday 22nd June, 2007
|
|
|
|
|
Hi,
I have a question on how to share a class between different projects in VC++.
I have an application project namely ImageApp.exe. It needs another dll project SubFunctions1.dll to run.
In the ImageApp project, I defined and used a class CMyControl. Now, the project SubFunctions1 needs use this class as well.
Since the CMyControl is small, I prefer not putting it in an additional dll project. Is there a better way to share the CMyControl?
|
|
|
|
|
One simple way to gather together small classes is to put them in a common static library (not dll) that you can link with as needed. The code will be linked into your app (or dll), and you do not need to distribute the static library.
|
|
|
|
|
Adding on to what Hans said, you can also export the necessary functions that you need from another class (or the entire class itself) via __declspec(dllexport) and import them from the class where you want to use them with __declspec(dllimport), provided your compiler supports these keywords (MSVC does). One way you can do this is through the following:
#ifndef _EXPORT
#define THEAPI __declspec(dllimport)
#else
#define THEAPI __declspec(dllexport)
#endif
class THEAPI TheClass
{
};
There are a few things you have to do:
1 - Define _EXPORT in the project that you want to export, and don't define _EXPORT in the project where you want to import the class/functions (this can be changed in VC++ project settings under preprocessors).
2 - Include TheClass.h from your main project, where you want to call the functions.
3 - Link with the .lib generated by the exported project from the project where you want to import (these .lib do not contain the full information, only how to link with the DLL).
I believe the above is known as static linking with DLLs, and you must package the DLLs with your executable on deployment. Static linking with the standard .lib will group everything in the .lib with your executable, which is why you can only distribute the executable.
One other way you can link (again with DLLs) is through the use of GetProcAddress() and LoadLibrary() to dynamically load DLLs during runtime, but for the sake of keeping it simple, you might want to just stick with Hans' suggestion or my suggestion above.
|
|
|
|
|
Cyrilix wrote: I believe the above is known as static linking with DLLs
or dynamic linking, early binding
"I'm the Dude. So that's what you call me. You know, that or, uh, His Dudeness, or uh, Duder, or El Duderino if you're not into the whole brevity thing." The Big Lebowski
|
|
|
|
|
I stand corrected.
|
|
|
|
|
I never said I was correct!
"I'm the Dude. So that's what you call me. You know, that or, uh, His Dudeness, or uh, Duder, or El Duderino if you're not into the whole brevity thing." The Big Lebowski
|
|
|
|
|
Hi, Guys,
Great suggestions! I will take all of your points.
Thanks a lot!
Skywalker2008/Stanley Hu
|
|
|
|
|
I have a resource dll into which I placed about 12 32-bit (with alpha) bitmaps. I've been trying to load them from the dll WITHOUT using the dll header but can't figure it out. Can anyone give me some advice/examples of how to do this?
|
|
|
|
|
Maybe the LoadImage() API? I'm not positive ARGB bitmaps are supported - it may require the
LR_CREATEDIBSECTION flag.
GDI+ has a Bitmap class constructor that takes an HINSTANCE and a resource name as well.
LoadLibrary() will get you the HINSTANCE of the resource DLL.
Mark
"I'm the Dude. So that's what you call me. You know, that or, uh, His Dudeness, or uh, Duder, or El Duderino if you're not into the whole brevity thing." The Big Lebowski
|
|
|
|
|
Loading the bitmap onto the screen is not the problem... The ARGB's show up just fine with the LoadImage function. The problem is getting the bitmap OUT of the dll. I load the dll but can't get a handle to the bitmap inside. I'm trying to avoid using the header file if I can... For instance, when loading icons from a dll, you can use the ExtractIcon function and it's pretty simple. I'm looking for a way to load a bitmap in this manner.
|
|
|
|
|
So you don't know the name (or ID) of the bitmap you want to extract?
If so, you can enumerate all the bitmap names in the DLL with
EnumResourceNames(hDllModule, RT_BITMAP, ...).
I'm not sure how you determine which one you want...by index I suppose, although I'm not sure
if the order the names are sent to the callback are in a defined order
Mark
"I'm the Dude. So that's what you call me. You know, that or, uh, His Dudeness, or uh, Duder, or El Duderino if you're not into the whole brevity thing." The Big Lebowski
|
|
|
|
|
I know the name of them... But when I try to use FindResource or LoadImage (or anything else that gets a handle) I get an error saying that "the specified resource was not found in the image file"
|
|
|
|
|
Ok, didn't you say you had no problem loading them and displaying them with LoadImage()?
What kind of handle are you trying to get?
You should have a valid HMODULE/HINSTANCE for the DLL to start with, or else it will never work.
You can get that by loading the DLL with LoadLibrary();
Then you need a valid name - if it's an integer ID then use the MAKEINTRESOURCE macro to convert the ID to a name "string".
HMODULE hResDLLModule = ::LoadLibrary(_T("c:\\path\myresdll.dll"));
if (hResDLLModule)
{
HBITMAP hBitmap = (HBITMAP)::LoadImage(hResDLLModule, MAKEINTRESOURCE(IDB_BITMAP), ...);
...
::FreeLibrary(hResDLLModule);
}
"I'm the Dude. So that's what you call me. You know, that or, uh, His Dudeness, or uh, Duder, or El Duderino if you're not into the whole brevity thing." The Big Lebowski
|
|
|
|