Excizted 67 Posting Whiz

>>oes the child class have access to those, too then?
No.

Great, thanks :) :)

Excizted 67 Posting Whiz

Okey then. Just had that impression, because I would use two constructors :)

Would you happen to be in such a good mood, you could tell me one more thing? :D
I'm wondering if I in a third class have set my parent class as friend, so that the parent class have access to the third class's protected functions. Does the child class have access to those, too then?

Excizted 67 Posting Whiz

Looks like a school assignment...
Can't believe you go to school if you don't want to learn anything, which is what comes out of this kinda stuff.. No learning.

Excizted 67 Posting Whiz

Hi.

I have a little question, that which answer may mean death to my class plans.

I have a superclass (or parent class if you will) that I have to delete when I'm done with it, but does that affect the subclass (or child class if you will)?

Simple question, hope the answer is as simple :D

Thanks'es.
-Excizted.

Excizted 67 Posting Whiz

and replace and swap? :P

Excizted 67 Posting Whiz

I want to put this code into separate window so that the results are displayed in a custom window not in a command prompt

#include <iostream>
#include <string>

using namespace std;



void main()
{
	system("title Find Mac From IP");
	system("cls && Color DF");
	cout<<"--------------------------------------------------------------------------------\n";
	cout<<"          This Utility is designed to test the client connectivity\n";
	cout<<"                   and get the MAC address of the System \n";
	cout<<"--------------------------------------------------------------------------------\n";
    std::string ip1,ipc1;
    cout<<"Enter the Ip Address:\t ";
    cin >> ip1;
    ip1 = "ping " + ip1;
    system(ip1.c_str());
    ipc1 = "nbtstat -A" + ip1;
	system(ipc1.c_str());
	system("prompt $");
	system("shift");
	
}

Well, now you are moving into the Windows API.

Thats a big difference from the console application.

If you are using Visual C++, you could take a look at the template code when creating a Win32 Project.

Alternately, for a very simple application you could use the Windows Forms Application type (also in VC++), which gives easy toolbox for adding labels, textbox, well all those different things you see around in windows.
I usually use the Windows Forms Application for creating tools for other things. Fx a calculator with custom functionality, or a password generator, or a value converter.

It takes some time getting into this Windows (crap) coding, and I know you'll love having to convert stuff :D

Atleast I hope you can get started, or look at something.

Excizted 67 Posting Whiz

Tried debugging? ^_^

Excizted 67 Posting Whiz

omg, use code tags.
[-code][/-code]
without the dashes, that'd make people like me want to help you ;D

Excizted 67 Posting Whiz

static __declspec(dllexport) int InsertMsg(String^ myTable);

Why dont you add __declspec(dllexport) to the class instead?
Why do you need ^ ? (String^ myTable)


My Log class in Dll works fine using strings in functions :) And those two things i mentioned above, seems to be the onlything generally different.

Excizted 67 Posting Whiz

Are you sure those calculations are correct?

It is clock time.. 0100 = 01:00, so 1AM :)

Excizted 67 Posting Whiz

When I run what i have so far, it prints out my introduction. i cant figure out how to hardcode my data file either. also i am supposed to use at 7 different functions in this program and am unsure as to what types of i would need.

Hardcoding your drinks shouldn't be that hard.
Why dont you just make a big string with them? I mean, thats a simple way to do it, but theres many options :)

Excizted 67 Posting Whiz

Files too. Sorry I forgot to mention that.

Then with the windows header (windows.h) you can use FindFirstFile.

Example of usage:

WIN32_FIND_DATA findFileData;
HANDLE hFind;
hFind = FindFirstFile((LPCSTR)"C:\\Users\\Local Settings\\Temp\\*", &findFileData);
if(hFind != INVALID_HANDLE_VALUE)
{
string filename(findFileData.cFileName);
cout << filename;
} 

while(FindNextFile(hFind, &findFileData))
{
string filename(findFileData.cFileName);
cout << filename;
}

That should get you started, otherwise ask :)

iDevelop commented: Thank You SO Much!! +0
Excizted 67 Posting Whiz

Do you need to delete only folders or files too? :)

Excizted 67 Posting Whiz

Hello all :)

I'm working on a DLL with various of functions I later need in other applications. I have many classes, and most of them I need a global instance of. I've tried various things such as a singletonptr, singleton, global instantiation.

What I need to achieve is the ability to use the same instance of a class from the client application, but also in the DLL.

An example of what I want to be able to:

DLL_Log:

void createLog(){ create_txt_file(); and_save_pointer(); }
void writeToLog(message){ open_txt_file(with_saved_pointer()); }

DLL_Math:

void AplusB(int a, int b){ log_class->writeToLog(a+b); }

EXE_Main:

log_class->createLog();
log_class->writeLog("application started!");
math_class->AplusB(5, 20);

Now the log file should be something like "Application started" "25".

In what I have made, I would get two different log classes, one in the DLL and one in the EXE.

What ways are there to do this?
Sorry for the poor sample code, but I didn't have anything small I could copy over.

Thanks
- Excizted :)

Excizted 67 Posting Whiz

Uhm.. I don't see your question anywhere? :)

Excizted 67 Posting Whiz

I'm new to using C++ but I thought I would give it a try. The goal is to delete all files and folders located in %userprofile%\Local Settings\Temp without deleting the folder called "Bluezone" located in the Temp folder. Any help would be appreciated.

Theres several ways you could do this :)
What comes to my head would be:

  1. List all folders and delete them individually if(name != "bluezone") ;)
  2. Take a backup of Bluezone, wipe it all out, and restore from the backup.
Excizted 67 Posting Whiz

I wonder if there is any function that returns the difference in minutes for examples like this:

1300-1515 (135 minutes)

2350-0100 (70 minutes)

Is there any timefunction that can have the ability to return the minutedifference ?

I don't think there is. It shouldn't be hard to make one yourself tho :)

Excizted 67 Posting Whiz

Whats your question, really?
You want help to loop, and include a sample. Please tell us what you want to achieve :)

Excizted 67 Posting Whiz

No one has a clue?

Excizted 67 Posting Whiz

Hello! :)

I'm trying to achieve an 'engine' of a kind in a DLL project. I have successfully made a DLL that works, but as simple as Hello World.

Now I'm coding a framework into the DLL project, but I'm having some trouble with the singleton function.

Im getting this linker error:

DLLProject.obj : error LNK2001: unresolved external symbol "public: static class MyDLL::Framework * MyDLL::Framework::ofManager" (?ofManager@Framework@MyDLL@@2PAV12@A)

DLLProject.h

namespace MyDLL
{
  class Framework
  {
  public:
    static __declspec(dllexport)  Framework* ofManager;
     Framework();
    ~Framework();
    static __declspec(dllexport) Framework* createManager();
    static __declspec(dllexport) Framework* getSingletonPtr()
    {
      return ofManager;
    };
    ...
  private:
    ...
  };
}

DLLProject.cpp

#include "DLLProject.h"
namespace myDLL
{
  Framework::Framework()
  {
    ofManager = this;
  }
  Framework* Framework::createManager()
  {
    if(ofManager == 0) ofManager = new Framework();
    return ofManager;
  }
  ...

Hope anyone can help, I'm really putting my hair out over this, and hoped that the time invested would not get me asking for help, but oh ;)

Excizted 67 Posting Whiz

I'll stick with just the code please ;)

Alright, I'm attaching it here then.
Please dont comment on code not related to my current problem - I'm aware of any problems elsewhere :)

I appreciate your help :D

Excizted 67 Posting Whiz

Uhm you want a compilable project or just the code? Because my project has a few dependencis.
MySQL is a killer: 500 MB :P

Excizted 67 Posting Whiz

So let me get this right, you basically have an array of hWnd's which all link to the same event handler, but you want to do different things with each of them in the messengerBox dialog when it's opened.

Even if I understood correctly, it depends what kind of changes will be in each new messengerBox dialog, will it have a totally new layout? or different data in the text fields?

More code, screenshots, anything to describe it better would be helpful.

Obviously the use of arrays here has made this very confusing, maybe it's possibly to do without, I don't know. But all I can suggest is to try using global variables and message notifications too, at this stage in making the program you have the biggest understanding of the problem and your intentions, so it's easiest for you to solve (unless perhaps I take a look at the entire project).

Well I have used many hours, and unlike normally, I'm completely clueless.
I'd be very glad if you could help me, and I could send over my project if thats what it takes. Its a bit too long to be posted here.
:)

Excizted 67 Posting Whiz

So let me get this right, you basically have an array of hWnd's which all link to the same event handler, but you want to do different things with each of them in the messengerBox dialog when it's opened.

Even if I understood correctly, it depends what kind of changes will be in each new messengerBox dialog, will it have a totally new layout? or different data in the text fields?

More code, screenshots, anything to describe it better would be helpful.

You do understand correctly. The eventhandler needs to be able to do two things. Hide the window, and send messages.

I have a thread that frequently checks for new messages, and then it sends the message to the textfield in the hWnd as so:

SendMessage(GetDlgItem(contact[atoi(row[2])].hWnd,IDC_EDIT1), WM_SETTEXT, 0, (LPARAM) convertCharTCHAR(row[3]));

Row[2] contains the sender ID, so we send the text to the dialog matching ID with sender ID.

This works fine.

Now I want to be able to, from the dialog, send messages, but I cant figure out how to sepparate the dialogs and get the contact.hWnd (to hide window) and the contact.id to send a message back.

Cheers for helping :)

Excizted 67 Posting Whiz

I would know the hWnd for my logon dialog, or my update dialog - but there is a contact dialog for each contact of the user.

while(row = get_users_contacts()){
contact[atoi(rowC[0])].hWnd = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG4), hWnd, messengerBox);}

So we have a dialog hWnd in contact[0].hWnd, contact[1].hWnd, etc.
But all these hWnds are linked to the messengerBox (BOOL CALLBACK messengerBox(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)). How do i make hWnd-individual actions in the messengerBox code?

Excizted 67 Posting Whiz

Hi.

I have a problem I cant find a solution to, since I am unable to describe the problem in a searchable way.

I make a hWnd for each contact the user has:

contact[atoi(rowC[0])].hWnd = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG4), hWnd, messengerBox);

messengerBox is defined like this.

BOOL CALLBACK messengerBox(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch(message)
	{
		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
				case WM_DESTROY:
					//ShowWindow(???,SW_HIDE);
				break;
			}
		break;
		default:
			return FALSE;
	}
	return TRUE;
}

I want the user to be able to hide the dialog - and also get the number of the struct character[] it is in, but I dont know how to get the hWnd, since it is dynamically stored in a variable.

Hope you understand! :)

Cheers.

Excizted 67 Posting Whiz

Sorry I have been offline for a while.. Ty your sonution worked! :D

Excizted 67 Posting Whiz

1) Are you compiling for UNICODE?

2) what compiler

3) how is UPDATE_DIR declared

4) note that %s and %S are not the same thing. See this

1) I am compiling UNICODE.
2) VC++
3) #define UPDATE_DIR "updateContent"
4) I'll read that, thanks.

Try

// wcstombs(char *mbstr,const wchar_t *wcstr, size_t count)
//
...
CHAR *mbBuf= new CHAR[100];
TCHAR *wcBuf=_T("hello");
#ifdef _UNICODE
wcstombs(mbBuf,wcBuf,100);
#else
strcpy(mbBuf,wcBuf);
#endif
...
delete[]mbBuf;
...

wcstombs, strcpy are deprecated..
More secure versions are available..
Take care..

Thank you for the answer.
- But I cant figure out where, in this code, my own stuff is to be placed.

Excizted 67 Posting Whiz

Hello DaniWeb. ;)

I have a problem with char->tchar conversion, that i cant seem to solve. I want to launch another program, anh the relative path to that program is fetched from MYSQL.

updateBox = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG2), hWnd, updateDiag);
hThread = (HANDLE)_beginthreadex(NULL, 0, Blah::Start, NULL, NULL, NULL);
_stprintf(patcherLoc, _T("%s/Patcher %s.exe"), UPDATE_DIR, row[2]);
strcpy(patcherUrl, row[3]);

I have tried like anything i could find on google, fx MultiByteToWideChar() - i even gone as far as to write it to a char, write the char to a file, read, and then in tchar format, from the file.

The TCHAR just contains some chineese symbols, and the only readable being "/Patcher" and ".exe".

It really just needs to be LPCTSTR-readable, so my ShellExecute will work.

MessageBox(hWnd, patcherLoc, _T("Error"), MB_OK | MB_ICONEXCLAMATION);
ShellExecute(NULL, NULL, patcherLoc, NULL, NULL, SW_SHOWNORMAL);

I use the messagebox to monitor how my TCHAR is doing.


I hope anyone can help me solve this problem.

Cheers :)

Excizted 67 Posting Whiz

Thank you very much! (:

Excizted 67 Posting Whiz

Use multiple threads?

Aha. Yeah it seems obvious now. Give the download tast it's own thread. Just hope my progressbar will still work.
Thanks (:

Excizted 67 Posting Whiz

Hello eveyone! :)

I am making a rather huge application, and I'm starting to face a global problem.

Whenever my application is doing sommething, i have a functional progress bar setup to show the progress. My problem is now, that, atleast on Windows Vista / Windows 7, my application whitens and is claimed not to be responding!

With a quick CURL download-script I can in Windows see the file grow, so yes, the application IS doing something.

I use the CURL buildin progress function to update my bar.

curl_easy_setopt(curl, CURLOPT_URL, "ftp://localhost/myFile.exe");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, prog_cb);
static int prog_cb (void *p, double dltotal, double dlnow, double ult, double uln){
SendMessage(GetDlgItem(updateBox,IDC_PROGRESS1), PBM_SETPOS, dlnow/dltotal*100, NULL);
return 0;
}

How do i make my Win 32 application stay active while CURL get my file?

As mentioned, my progress bar IS working, until the window turn inactive as "not responding".

Hope it is possible to understand my question (:
- Regards, Excizted.