Visual C++ :: Calling A Function In AfxBeginThread?
Oct 1, 2014
I have the code:
void go(CMFCApplication1Dlg * pdlg)
{
pdlg->listcontrol1.InsertItem(0, "Row1");
}
then i call it in thread
Code:
void CMFCApplication1Dlg::OnBnClickedButton3()
{
AfxBeginThread(go(this), NULL, THREAD_PRIORITY_NORMAL, 0, 0, NULL);
}
It doesn't work.
View 13 Replies
Feb 2, 2014
Following function is causing run-time assertion. I am using VC6.0 professional version. My OS is Win7.0. I am calling the function from OnDraw. OnDraw does not contain any other code other than the function call code:
Code:
void CMoireUseCirclesView::UseCircle(CDC* pDC){
int x1, y1, x2, y2;
x1=20;
y1=100;
x2=200;
y2=280;
int color1=0;
int color2=0;
[Code] ....
The assertion is occurring at:
Code:
newPen.CreatePen(PS_SOLID,5, RGB(color1,color2,color3+i));
The error message is:
Debug Assertion Failed
Prog:....
File:wingdi.cpp
Line:1120
Debug is giving following values
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:WindowsSysWOW64kernel32.dll', no matching symbolic information found.
Loaded 'C:WindowsSysWOW64KernelBase.dll', no matching symbolic information found.
Loaded symbols for 'C:WindowsSysWOW64MFC42D.DLL'
[Code] ...
View 7 Replies
View Related
Feb 7, 2013
The code below outputs this:
a[]= 00
a[]= 10
a[]= 10
a[]= 10
a[]= 11
a[]= 11
0.
But I was expecting this:
a[]= 00
a[]= 10
a[]= 10
a[]= 00
a[]= 01
0.
This describes how the process is running in machine:
1. Defining a[2]{0,0}; ii=0; aj=0
2. Calling function func(a,ii,aj) |func({0,0},0,0)|
3. func({0,0},0,0) defining w=0; static aa=0
4. func({0,0},0,0) if(0) returns aa=1
5. func({0,0},0,0) for j=0
6. func({0,0},0,0) for Outputing "00", because a[2]={0,0}, look (1).
7. func({0,0},0,0) for if(!0) | because a[0]=0| returns w+=func(a,ii+1,j) |func({0,0},0+1,0)| and calls func({0,0},1,0)
8. func({0,0},0,0) for if func({0,0},1,0) defining w=0
9. func({0,0},0,0) for if func({1,0},1,0) if(1) returns a[0]=1, because of static aa=1, см 4.
10. func({0,0},0,0) for if func({1,0},1,0) for j=0
11. func({0,0},0,0) for if func({1,0},1,0) for Outputing "10", because of a[2]={1,0}, look row #9
12. func({0,0},0,0) for if func({1,0},1,0) for if(!1) |because a[0]=1|
13. func({0,0},0,0) for if func({1,0},1,0) for j=1
14. func({0,0},0,0) for if func({1,0},1,0) for Outputing "10"
15. func({0,0},0,0) for if func({1,0},1,0) for if(!0) |because a[1]=0|
16. func({0,0},0,0) for if func({1,0},1,0) for if if(1==1) |because ii=1, func({0,0},ii,0)|
17. func({0,0},0,0) for if func({1,0},1,0) for if if return 0
18. func({0,0},0,0) for if w=0 |because func({1,0},1,0) gives 0|
19. func({0,0},0,0) for j=1
And from now, something is happening that I cannot understand:
20. func({0,0},0,0) for Outputing "10"
Why so? If func has itselfs local variables, including a[2]={0,0}.
I was expecting this:
20. func({0,0},0,0) for Outputing "00"
So a[2] array is not local variable. Why it happens?
Code:
#include <iostream>
using namespace std;
int func(bool a[],int ii,int aj) {
int w=0;
static bool aa=0;
[Code] ....
View 3 Replies
View Related
Feb 19, 2014
Is this possible?
int myfunc( int a, int b, char * c )
char a = "(int)myfunc()";
char b = "(int,int,char*)"
call(a, b, ...) // Function name and return type, params
I want to do function what registers forward what will get callback if the time is right. Basically then i dont need to edit and add extra functions into source files. I just have to include header and use register forward function. If there is anything close to this it would be perfect!
View 5 Replies
View Related
Jun 8, 2014
I have this sample code, that calls a function in a DLL. The function Callback is provided to the DLL as an argument, in order for the DLL to notify my program of relevant changes.
sample:
#include <iostream>
#include <conio.h>
#include <windows.h>
#include <winbase.h>
#include "TcAdsDef.h"
#include "TcAdsApi.h"
using namespace std;
void _stdcall Callback(AmsAddr*, AdsNotificationHeader*, unsigned long);
[Code] ....
I would like to change this code, so that there is a Main class that opens the connection and there are several separate classes (as below) that register themselves for a specific variable and get notifications if that value is changed. The reason for this is that I want to get several notifications for several independent events and I don't want them to mix. I figured this should look something like this:
class.h
#ifndef INACLASS_H
#define INACLASS_H
#include "Main.h"
class InAClass {
public:
InAClass(Main* mainClass, std::string iolocation);
[Code] ....
Unfortunately this gives me an error:
error: cannot convert 'InAClass::Callback' from type 'void (InAClass::)(AmsAddr*, AdsNotificationHeader*, long unsigned int)' to type 'PAdsNotificationFuncEx {aka void (__attribute__((__stdcall__)) *)(AmsAddr*, AdsNotificationHeader*, long unsigned int)}'
At first I thought this was because I don't have the namespace "using namespace std;" on top, but then I should be able to find something that specifically needs to come from the std namespace and is not marked as such. I don't want to rule the option out, but so far I could not find anything like that.
An alternative explanation might be that the Callback function needs to be global, but if I make it global, how can I distinguish between several Callback functions?
View 7 Replies
View Related
Apr 3, 2013
I am trying to use ofstream to write in a txt file in a function called recurrently. for a simplified example:
void func_write(double x) {
ofstream myfile;
myfile << "the result = " << x << endl;
} int main() {
ofstream myfile;
[Code] .....
To this stage, it does not work, because the myfile in func_write cannot write in the txt file opened in main function. I don't want to open, append and close the txt file each time the function is called, that will take more time to execute all (imagine with 500 calls).
View 2 Replies
View Related
Feb 20, 2013
I have two functions bool check_key(string cKey, string eKey) and bool check_digit(char digit1, char digit2), and I have declared both of them globally (is this the right terminology?) right after the "using namespace std;" and right before the "int main(){".
In the first one, I called the second one . But it is giving me the error: "no match for call to `(std::string) (int&)' ".
Code:
bool check_key(string cKey, string eKey) {
if(cKey!="" && eKey=="") return false;
if(cKey=="" && eKey=="") return true;
if(cKey=="" && eKey!="") return true;
if(cKey.length()!= eKey.length()) return false;
bool flag=true;
[Code] ....
View 2 Replies
View Related
Oct 11, 2013
I have a COM Object created using ATL (without MFC Support)
The Object has 1 method that opens a Dialog (that does all the rest) and when finish - returns 2 values back (1 is enough)
Currently I call it from another EXE:
hr = CoCreateInstance(
CLSID_MyControl,
NULL,
CLSCTX_INPROC_SERVER,
IID_IMyControl,
(void**) &pMyControl
);
and then:
hr = pMyControl->MyMethod (ATL::CComBSTR(InputString1), ATL::CComBSTR(InputString2), &IntReturned, &IntReturned);
Is it possible to call it as is from a browser ?
How can I Instantiate the object and invoke my method (with params) from the browser ?
will it open the dialog ?
View 3 Replies
View Related
Sep 12, 2013
I'm new to C/C++. I'm trying to make a program that's going to use the CBLAS libraries that I downloaded on BLAS. After fighting tooth and nail with VC 2005 (I downgraded on purpose because at one point I was desperate.) with regards to solving compilation errors and such and eventually it all compiled just fine.
The problem now is, I get the above mentioned error. It says: "Unhandled exception at 0x0040271c in Try.exe: 0xC0000005: Access violation reading location 0x4e18feb8."
Now there are a few .cpp files (I'm compiling as C code.) which contain the functions and there is one other one which contains my main method. Using the debugger, it goes through 3 files all in all.
The main file: Code: /* cblas_example2.c */
#include <stdio.h>
#include <stdlib.h>
#include "cblas.h"
#include "cblas_f77.h"
[Code] .....
I get the above-mentioned exception in the last line, or:
Code: cblas_dgemm( UNDEFINED, transa, transb, *m, *n, *k, *alpha, a, *lda, b, *ldb, *beta, c, *ldc );
The debugger tells me what the address in the exception is the address if *ldc.
View 6 Replies
View Related
Mar 7, 2014
Code:
const MenuData breakfast[NUMOFBREAKFASTITEMS] = {
{"Egg Breakfast", "Two eggs with a side of bacon and two slices of toast.", "", "2 Eggs, 2 Toats, 2 Bacons", "", 250.00},
{"Pancake Breakfast", "Three Buttermilk pancakes served with butter and syrup.", "", "Three Pancakes, Butter, Syrup", "", 200.00},
[Code]....
What I'm trying to do is call the printReceipt function in the main, but I'm doing it wrong. Here is my attempt.
Code:
printReceipt (const MenuData menu[], qty, info)
I've tried it many other ways but I keep getting an error. I tried researching it on the internet, but I don't get much info.
View 14 Replies
View Related