According to the Criminal Code of Canada, you can only generally be convicted of an offence that was included as part of your original charge. For example, you couldn't be charged only with forgery and then be convicted of murder. However, there are some specific exceptions to that rule.
Sections 660-662 of the Criminal Code covers these exceptions:
Full offence charged, attempt proved
660 Where the complete commission of an offence charged is not proved but the evidence establishes an attempt to commit the offence, the accused may be convicted of the attempt.
Attempt charged, full offence proved
661 (1) Where an attempt to commit an offence is charged but the evidence establishes the commission of the complete offence, the accused is not entitled to be acquitted, but the jury may convict him of the attempt unless the judge presiding at the trial, in his discretion, discharges the jury from giving a verdict and directs that the accused be indicted for the complete offence.
Offence charged, only part proved
662 (1) A count in an indictment is divisible and where the commission of the offence charged, as described in the enactment creating it or as charged in the count, includes the commission of another offence, whether punishable by indictment or on summary conviction, the accused may be convicted
(a) of an offence so included that is proved, notwithstanding that the whole offence that is charged is not proved; or
(b) of an attempt to commit an offence so included.
First degree murder charged
(2) For greater certainty and without limiting the generality of subsection (1), where a count charges first degree murder and the evidence does not prove first degree murder but proves second degree murder or an attempt to commit second degree murder, the jury may find the accused not guilty of first degree murder but guilty of second degree murder or an attempt to commit second degree murder, as the case may be.
Conviction for infanticide or manslaughter on charge of murder
(3) Subject to subsection (4), where a count charges murder and the evidence proves manslaughter or infanticide but does not prove murder, the jury may find the accused not guilty of murder but guilty of manslaughter or infanticide, but shall not on that count find the accused guilty of any other offence.
Conviction for concealing body of child where murder or infanticide charged
(4) Where a count charges the murder of a child or infanticide and the evidence proves the commission of an offence under section 243 but does not prove murder or infanticide, the jury may find the accused not guilty of murder or infanticide, as the case may be, but guilty of an offence under section 243.
Conviction for dangerous operation where another offence charged
(5) For greater certainty, when a count charges an offence under section 220, 221 or 236 arising out of the operation of a conveyance, and the evidence does not prove that offence but proves an offence under section 320.13, the accused may be convicted of an offence under that section.
Conviction for break and enter with intent
(6) Where a count charges an offence under paragraph 98(1)(b) or 348(1)(b) and the evidence does not prove that offence but does prove an offence under, respectively, paragraph 98(1)(a) or 348(1)(a), the accused may be convicted of an offence under that latter paragraph.