Alright, I have my GUI written in C and the other document is in command-line and written in C++. I'd like to merge one code with another on a click of a certain menu item and I do not know how to do so.
My main.cpp looks like this:
#include <windows.h><br />
#define IDR_MYMENU 101//Defines the menu ID<br />
#define IDI_MYICON 201//Defines the Icon ID<br />
#define ID_FILE_EXIT 9001//Defines menu item "Exit"<br />
#define ID_CONVERT_MM 9002//Defines menu item "MessengerMate"<br />
#define ID_CONVERT_MIDDLE 9003//Defines menu item "Middle_Man(Coming Soon..)"<br />
<br />
<br />
const char g_szClassName[] = "myWindowClass";
<br />
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{<br />
switch(msg)<br />
{<br />
case WM_CREATE:
{<br />
HMENU hMenu, hSubMenu;<br />
HICON hIcon, hIconSm;<br />
<br />
hMenu = CreateMenu();<br />
<br />
hSubMenu = CreatePopupMenu();<br />
AppendMenu(hSubMenu, MF_STRING, ID_FILE_EXIT, "E&xit");<br />
AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&File");<br />
<br />
<br />
hSubMenu = CreatePopupMenu();<br />
AppendMenu(hSubMenu, MF_STRING, ID_CONVERT_MM, "&MessengerMate");<br />
AppendMenu(hSubMenu, MF_STRING, ID_CONVERT_MIDDLE, "&Middle_Man(Coming Soon..)");<br />
AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&Convert to..");<br />
<br />
SetMenu(hwnd, hMenu);<br />
<br />
<br />
hIcon= LoadImage(NULL, "RidV.ico", IMAGE_ICON, 32, 32, LR_LOADFROMFILE);<br />
if(hIcon)<br />
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);<br />
else<br />
MessageBox(hwnd, "Could not load large icon!", "Error", MB_OK | MB_ICONERROR);<br />
<br />
hIconSm= LoadImage(NULL, "RidV16.ico", IMAGE_ICON, 16, 16, LR_LOADFROMFILE);<br />
if(hIconSm)<br />
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm);<br />
else<br />
MessageBox(hwnd, "Could not load small icon!", "Error", MB_OK | MB_ICONERROR);<br />
}<br />
break;<br />
case WM_COMMAND:<br />
switch(LOWORD(wParam))<br />
{<br />
break;<br />
<br />
case ID_FILE_EXIT:
PostMessage(hwnd, WM_CLOSE, 0, 0);<br />
break;<br />
case ID_CONVERT_MM:<br />
<br />
break;<br />
case ID_CONVERT_MIDDLE:<br />
<br />
break;<br />
}<br />
<br />
break; <br />
case WM_CLOSE:
DestroyWindow(hwnd);<br />
break;<br />
case WM_DESTROY:
PostQuitMessage(0);<br />
break;<br />
default:<br />
return DefWindowProc(hwnd, msg, wParam, lParam);<br />
}<br />
return 0;<br />
}<br />
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,<br />
LPSTR lpCmdLine, int nCmdShow)<br />
{<br />
<br />
WNDCLASSEX wc;<br />
HWND hwnd;<br />
MSG Msg;<br />
<br />
wc.cbSize = sizeof(WNDCLASSEX);<br />
wc.style = 0;<br />
wc.lpfnWndProc = WndProc;<br />
wc.cbClsExtra = 0;<br />
wc.cbWndExtra = 0;<br />
wc.hInstance = hInstance;<br />
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);<br />
wc.hCursor = LoadCursor(NULL, IDC_ARROW);<br />
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);<br />
wc.lpszMenuName = NULL;<br />
wc.lpszClassName = g_szClassName;<br />
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);<br />
<br />
if(!RegisterClassEx(&wc))<br />
{<br />
MessageBox(NULL, "Window Registration Failed!", "Error!",<br />
MB_ICONEXCLAMATION | MB_OK);<br />
return 0;<br />
}<br />
<br />
hwnd = CreateWindowEx(<br />
WS_EX_CLIENTEDGE,<br />
"myWindowClass",<br />
"Alias Converter by Ridv",<br />
WS_OVERLAPPEDWINDOW,<br />
CW_USEDEFAULT, CW_USEDEFAULT, 500, 500,<br />
NULL, NULL, hInstance, NULL);<br />
<br />
if(hwnd == NULL)<br />
{<br />
MessageBox(NULL, "Window Creation Failed!", "Error!",<br />
MB_ICONEXCLAMATION | MB_OK);<br />
return 0;<br />
}<br />
<br />
ShowWindow(hwnd, nCmdShow);<br />
UpdateWindow(hwnd);<br />
<br />
while(GetMessage(&Msg, NULL, 0, 0) > 0)<br />
{<br />
TranslateMessage(&Msg);<br />
DispatchMessage(&Msg);<br />
}<br />
return Msg.wParam;<br />
}<br />
<br />
and I want to incorporate this(da2mm.cpp) into the case ID_CONVERT_MM:
<br />
#include <iostream><br />
#include <fstream>
#include <string><br />
#include "find_daa.cpp"<br />
using namespace std;
<br />
inline string find_daa();
<br />
int main()
{<br />
string da;
<br />
da = find_daa();
<br />
if(da == "-1")
{<br />
cout << "No file was chosen or available for conversion" << endl;<br />
cout << "Program will now exit" << endl;<br />
system("pause");<br />
<br />
return -1;<br />
};<br />
<br />
ifstream daFile(da.c_str(), ios::in);<br />
<br />
if(!daFile)<br />
{<br />
cout << "File could not be opened or does not exist" << endl;<br />
cout << "Program will now exit..." << endl;<br />
system("pause");<br />
<br />
return -1;
};<br />
int pos = daFile.tellg();<br />
<br />
ofstream mmFile("mmaliases.reg");<br />
<br />
if(!mmFile)<br />
{<br />
cout << "File could not be created" << endl;<br />
cout << "Program will now exit..." << endl;<br />
system("pause");<br />
<br />
return -1;
};<br />
<br />
<br />
mmFile << "Windows Registry Editor Version 5.00" << endl << endl;<br />
mmFile << "[HKEY_CURRENT_USER\\Software\\Messenger:Mate\\AIM\\Profiles\\Default\\Aliases]" << endl;<br />
<br />
string sn;<br />
string alias;<br />
<br />
while(!daFile.eof())
{<br />
getline(daFile, sn, '\t');
getline(daFile, alias);
<br />
if(sn.empty() || alias.empty()) continue;
<br />
mmFile << "\"" << sn << "\"=\"" << alias << "\"" << endl;<br />
};<br />
<br />
daFile.clear();
daFile.seekg(pos, ios::beg);
mmFile << endl << "[HKEY_CURRENT_USER\\Software\\Messenger:Mate\\AIM\\Profiles\\Default\\Aliases\\RL]";<br />
mmFile << endl;<br />
<br />
while(!daFile.eof())
{<br />
getline(daFile, sn, '\t');
getline(daFile, alias);
<br />
if(sn.empty() || alias.empty()) continue;
<br />
mmFile << "\"" << alias << "\"=\"" << sn << "\"" << endl;<br />
};<br />
<br />
mmFile.close();<br />
daFile.close();<br />
<br />
system("REGEDIT /S mmaliases.reg");<br />
<br />
system("DEL mmaliases.reg");<br />
<br />
cout << "Thank you for using this conversion program written by: Ridv" << endl;<br />
system("pause");
<br />
<br />
<br />
return 0;
};<br />
and this is the second file(find_daa.cpp) to da2mm.cpp:
<br />
#include <errno.h><br />
#include <dirent.h>
#include <string><br />
#include <cctype><br />
using namespace std;<br />
<br />
string find_daa(void)<br />
{<br />
DIR *dir;
struct dirent *place;
string filename;
string ret;
int result;
char response;
<br />
dir = opendir(".");
<br />
if(!dir){
cout << "Could not open dir";<br />
system("pause");<br />
return "1";<br />
};<br />
errno = 0;
<br />
while(place=readdir(dir))
{<br />
filename.assign(place->d_name);
result = filename.find(".daa", 0);
if(result != string::npos)
{<br />
cout << "Would you like to convert " << filename << " ? [Y/N]" << endl;<br />
cin >> response;
response = tolower(response);
if(response == 'y')
{<br />
ret.assign(filename);
break;
}<br />
};<br />
};<br />
<br />
if(errno)
{<br />
cout << "Problem with readdir";<br />
system("pause");<br />
return "1";<br />
};<br />
if(ret.empty())
{ <br />
return "-1";<br />
}<br />
closedir(dir);
return ret;<br />
}<br />
All this info is just to give you an idea of what I want to do since I'm not too sure what the technical term for the procedure is. Also, whenever I move the installer out of the directory that the icons are in, it'll produce the errors and i'm wondering how to fix it to where no matter where the installer is, it shows the icons. Sorry i'm a newb.
Any help is greatly appreciated and if I have any other code wrong please inform me.
|