thats sort of what i was trying to avoid was a lot of extra work, way i once did it in c++ was i capped all my line sizes so i knew the max size i could work with but did not want this limitation in my new c# stuff, i appreciate the response and i have already thought about doing something very much like you mentioned.
swatgodjr
Posts
-
problem with writing files -
problem with writing filesi have written a program that keeps track of records in a data file and came across a small problem. writing to files for most part works fine except when i go to update entries, if the new entry is bigger than the old one it starts overwriting data ahead of the entry. if someone could give me soem advice on how i can prevent this i would very much appreciate it.
-
help with a small problemi have made a small application that can load programs compiled into dll files, i managed to get the application to load my dll files correctly but now i am having issues with how to unload the dll files correctly. inside the dll program, when i go to close the program i can not use the normal means to close as it would cause the whole program including the loader to close. so if someone could please give some advice on how to properly unload a dll after its loaded, it would be very much appreciated.
-
Help with DLL fileshi, i recently started rewriting a lot of my c++ code over to c# and have come across a very tough issue which i would really like some help solving. what i am trying to make is a program that allows a user to load a dll file at run time which the dll file would be a .net managed dll file like the application BUT i do not want the application to know anything about the dll files, i have seen a lot of stuff on doing this but so far not much of it has worked as i think i am not writing the dll file correctly, the dll file i would like to be able to use forms with and i think i have not done that correctly which is making it impossible to load the dll file correctly. so if someone could please show me something on how to write the dll file correctly so it can load forms properly and allow my application to load the dll file correctly, i would very much appreciate it. thank you in advance.
-
confusing problemwell i had it as global but because of how my code is set up, i can not really compile the program very easily without having to force the program to be compiled because it will get included more than once and the 15+ warnings it gives got annoying to look at and unless i do force it to compile than it will register as errors instead.
-
confusing problemhere is the function that has the problem:
typedef void (*MYPROC)(LPTSTR); MYPROC ProcAdd; BOOL fRunTimeLinkSuccess; Load *a; Loader *b; a->Hide(load_window); b->Hide(loader_window); hinstLib = LoadLibrary(program); if(hinstLib != NULL) { ProcAdd = (MYPROC)GetProcAddress(hinstLib, "?prog_start@@YAHXZ"); if(fRunTimeLinkSuccess = (ProcAdd != NULL)) { (ProcAdd)("?prog_start@@YAHXZ"); } else{ MessageBox(m_hWnd, "Program Failed to Load", "Fail", MB_ICONSTOP); EndDialog(m_hWnd, IDOK); } } else{ MessageBox(m_hWnd, "Loader Failed to open program", "Fail", MB_ICONSTOP); reportError(); } fFreeResult = FreeLibrary(hinstLib); b->Show(loader_window); a->Show(load_window);
not exactly the best way to load a dll file but it works for what i was doing right now to test stuff with. loader_window is the one that can not be seen, it is a hwnd variable to one of the windows in my program. and here is the code where i have everything being included:#ifndef MAIN_H #define MAIN_H #include #include #include "..\common\win32.h" #include "resource.h" #include "loader.h" #include "load.h" #include "help.h" #include "version.h" #endif
-
confusing problemhi, i have created a program that uses several different header files and to make it easy for all header files to access stuff i had all my cpp files just reference 1 file that includes all my header files. all of the files compile fine except 1 which complains about a undeclared variable that is part of one of my classes but what makes no sense is that that source file sees my class with that variable in it just fine and intellisense shows the class variable that is supposedly undeclared. thanks in advance for any advice anyone can give me.
-
problem with code after switching to visual studio 2005yes, thanks to your help it is fixed. thank you for the help.
-
problem with code after switching to visual studio 2005umm i just noticed something rather interesting. your code works perfectly and yet when i made the small change that you had made i still get no text and i think now i understand why that is. but also i have a function like that since i once had this program being used in a console app and in that version separated a lot of my most common chunks of code into a separate dll that i used in multiple programs and just have not gotten around to redoing the same process in my gui apps. and i also use /r and endl because if i don't it will not terminate and drop other pieces of text to another line with how i was doing text in my cedit boxes in my program.
-
problem with code after switching to visual studio 2005ok not a problem, i been constantly looking for ways to redo the code correctly but not much luck yet well heres the code to one part of my program:
const int TEXT_SIZE = 5000; char szbuf[TEXT_SIZE]; std::ostringstream str(szbuf); void CHelpDialog::help_mes(char num[], bool cnt, char mess[]) { if(cnt == true) { str << " " << num << ". " << mess << "\r" << std::endl; } if(cnt == false) { str << " " << mess << "\r" << std::endl; } } BOOL CHelpDialog::OnInitDialog() { CEdit *pHelpText; pHelpText = (CEdit *) GetDlgItem(IDC_HELPTEXT); str.seekp(0); help_mes("1", true, "Everything entered in this program is case-sensitive so if"); help_mes("", false, "your program fails to load when you type in name of the plug"); help_mes("", false, "in to load, check if you spelled it correctly with the right"); help_mes("", false, "capitalization.\n"); help_mes("2", true, "If the program you enter fails to load, make sure you have the"); help_mes("", false, "required dll files needed for the program."); help_mes("3", true, "If there is any more bugs found than please contact me to let me"); help_mes("", false, "know. I can be reached at swatgod@gmail.com.\n"); pHelpText->SetWindowText(szbuf); memset(szbuf, 0, sizeof(szbuf)); return true; }
that is all the code that basically deals with the problem area, any advice is very much appreciated :). -
problem with code after switching to visual studio 2005just recently got visual studio 2005 and well to put a long story short it has been driving me crazy lol. but anyways i had to switch from using soem of the old libraries to usign the new ones and it has caused nothing but trouble. in my vc 6 i had a piece of code that would put any text i passed into a ostrstrea object(which in 2005 now is ostringstream) and it was stored into a char buffer which i would pass the buffer off to the setwindowtext function of a cedit control and it would display any text in the buffer but after a few changes to allow my program to compile the text will not display and i am not quite sure why. i have the code set up to work as it did in vc 6 but i am not sure what changes were made that now causes it to fail in vc 8, if someone could help me figure out what might be wrong i would greatly appreciate it.
-
question about getfileattributes functioni tried to use INVALID_FILE_ATTRIBUTES and it returns an error on compiling saying that it was an undeclared identifier and also tried checking for the other error code but that just gives me the same error message i have been having when the function is called in my program. i have the correct files being included into my program so i really am not sure why it wotn let me use INVALID_FILE_ATTRIBUTES. also from what i have noticed, it never returns either error message as it goes to the main body of the function like it should.
-
question about getfileattributes functionactually i originally had it checking for INVALID_FILE_ATTRIBUTES but no matter what i did it kept giving me an error saying it was an undeclared identifier so i just put !attribList so that it would compile so that i could at least test it out. i included the files it needed and everything and after quite a bit of looking around i just left it the way i have it now. the code i posted was actually modified from my getlasterror function which works nicely.
-
question about getfileattributes functionyea as i explained i also tried this on a file i had not even touched at all and got the same error in doing so. is there maybe something wrong with my code i posted?
-
question about getfileattributes functioni have been able to get my program to compile correctly and added in code to view the returned result of the dword value from GetFileAttributes() which should display the file attributes of the given file but when the function is called all it returns is an error message saying "the process cannot access the file because it is being used by another process." yet i made sure that before it was called i had closed the file before the function was called and even tried the function on a file that was never opened and it still gave the same error. here is the code for my function:
ReportAttributes(char filename[]) { LPCTSTR pszCaption = "Debug Results:"; DWORD attribList = GetFileAttributes(filename); if(!attribList) { MessageBox("An Error Has Occured", pszCaption, MB_ICONWARNING); } else { const DWORD dwFormatControl = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM; LPVOID pTextBuffer = NULL; DWORD dwCount = FormatMessage(dwFormatControl, NULL, attribList, 0, (LPTSTR) &pTextBuffer, 0, NULL); if(0 != dwCount) { MessageBox((LPCSTR)pTextBuffer, pszCaption, MB_ICONERROR); LocalFree(pTextBuffer); } else { MessageBox("Unknown error", pszCaption, MB_OK); } } }
i varied the icons in the messagebox calls to see which one came up when the error was displayed. -
problem with setwindowtext()you know...i went back to check the ids and names of controls as you said to do...noticed that some how the names of controls in another window were being used in that window so i changed them to what they needed to be and well it works fine, now to see if i can get it to do what i need(which should be no problem at all.) thank you so much :).
-
problem with setwindowtext()sure not a problem, i will post the whole function, hope that will be enough to help solve the issue.
afx_msg void CEditDialog::OnEdit() { elements s; int size = sizeof(elements); bool found = false; //MessageBox(" This Area is Still under Construction", "Debug", MB_ICONINFORMATION); CComboBox *pSelection; pSelection = (CComboBox *)GetDlgItem(IDC_SELECTION); CEdit *pNameText; pNameText = (CEdit *) GetDlgItem(IDC_ENAME); CEdit *pSymbolText; pSymbolText = (CEdit *) GetDlgItem(IDC_ESYMBOL); CEdit *pAtomicText; pAtomicText = (CEdit *) GetDlgItem(IDC_EATOMIC); CEdit *pPeriodText; pPeriodText = (CEdit *) GetDlgItem(IDC_EPERIOD); CEdit *pGroupText; pGroupText = (CEdit *) GetDlgItem(IDC_EGROUP); CEdit *pElectronText; pElectronText = (CEdit *) GetDlgItem(IDC_EELECTRON); int iCurSel = pSelection->GetCurSel(); if(iCurSel == CB_ERR) { MessageBox(" Please Select an Item.", "Error", MB_ICONWARNING); return; } char lpszText[32]; pSelection->GetLBText(iCurSel, lpszText); access.Open(file, CFile::modeCreate | CFile::modeNoTruncate | CFile::modeReadWrite); do{ access.Read(reinterpret_cast< char * > (&s), sizeof(elements)); MessageBox(lpszText, "debug", MB_ICONINFORMATION); if(strcmp(s.element, lpszText) == 0) { access.Seek(-(long)size, CFile::current); MessageBox("Found", "debug", MB_ICONINFORMATION); found = true; pNameText->SetWindowText("test"); } }while(found != true); access.Close(); }
all the code works as expected except the setwindowtext, anythign i put for it to output causes a crash(please excuse my sloppy code). -
problem with setwindowtext()hi, i am writing a program that stores data into a text file i specify in the form of a class object. when i initialize the window where i can edit this data, i have a combo box that reads the file and inserts part of the object(the name of each class object) into the combo box. than i select the name and when i hit the button to edit the data for that particular object i am trying to have my program insert each part of the class into its own text box but when i try to do this my program completely crashes without any information as to why. i tried to push the values of the variables into a buffer and than use setwindowtext but it would still crash which i have done else where in my program without any bit of trouble.
-
Dll load problemthe way my app works is nothign really big and complicated, its just a simple program i made to mess aroudn with. i do not "install" it on a pc in any way, i just send it to friends to test if it works. basically you open the exe, go into a screen where you type in the dll to load and the program loads it. its not complicated at least not in my eyes. i did notice that on my pc loadlibrary call is all i need to load the dll file, i do not have to get any addresses to the functions. but when i tell it to do that it crashes after i close the dll. my consoel based version works perfectly on any pc yet migrating the whole thing over to gui based seems to have changed how it does the loading of my dll files.
-
Dll load problemi made the dll myself, i am using LoadLibrary to load it in my program. originally my application was console based and it ran perfectly, loaded on any pc i put it on. but since turnign it into a dialog based gui application, using the exact same loading code, it fails to load now on any pc but mine.